jichoi / lms_front star
정다정 09-11
240911 정다정 대화지문 듣기 기능 추가
@e7f383994cf00337b3fc642dc12f66518f6ffa83
 
client/resources/audio/passage/passage_explanation.mp3 (Binary) (added)
+++ client/resources/audio/passage/passage_explanation.mp3
Binary file is not shown
 
client/resources/audio/passage/passage_intoduce.mp3 (Binary) (added)
+++ client/resources/audio/passage/passage_intoduce.mp3
Binary file is not shown
 
client/resources/img/new_img/icon/play_icon.png (Binary) (added)
+++ client/resources/img/new_img/icon/play_icon.png
Binary file is not shown
client/views/pages/main/Chapter/Chapter1_2.vue
--- client/views/pages/main/Chapter/Chapter1_2.vue
+++ client/views/pages/main/Chapter/Chapter1_2.vue
@@ -23,22 +23,48 @@
             </div>
             <div class="content title-box">
                 <p class="title mt25 title-bg">step1. Hello WORLD</p>
+                <div class="flex align-center ml50 mb15" style="margin-top: -30px; gap: 10px">
+                    <h4>각 인물들의 대화를 듣고 읽어봅시다. 아래의 플레이버튼을 눌러 영어 발음을 들어보세요!</h4>
+                    <div class="listen-btn">
+                        <img src="../../../../resources/img/btn10_s.png" alt="" @click="playAudio" />
+                        <audio
+                            id="audio-player"
+                            src="client/resources/audio/passage/passage_intoduce.mp3"
+                            preload="auto"
+                        ></audio>
+                    </div>
+                </div>
                 <div class="flex justify-center">
                     <div class="readGroup">
-                        <h4>각 인물들의 대화를 집중해서 읽어보세요</h4>
                         <div>
                             <div class="textbox">
                                 <article
                                     v-for="(line, index) in combinedLines"
                                     :key="index"
-                                    :class="['flex', 'align-start', 'mb10', { 'justify-end': index % 2 !== 0 }]"
+                                    :class="['flex', 'align-center', 'mb10', { 'justify-end': index % 2 !== 0 }]"
                                 >
                                     <div v-if="index % 2 === 0" class="icon mr40">
                                         <img src="../../../../resources/img/img37_s.png" alt="" />
                                         <p class="name">{{ speakerA_name }}</p>
                                     </div>
                                     <p v-if="index % 2 === 0" class="read">{{ line }}</p>
+                                    <div class="listen-btn ml10" v-if="index % 2 === 0">
+                                        <img
+                                            src="../../../../resources/img/new_img/icon/play_icon.png"
+                                            alt=""
+                                            @click="generateTts('male', line)"
+                                        />
+                                        <audio id="tts-audio-player" preload="auto"></audio>
+                                    </div>
 
+                                    <div class="listen-btn mr10" v-if="index % 2 !== 0">
+                                        <img
+                                            src="../../../../resources/img/new_img/icon/play_icon.png"
+                                            alt=""
+                                            @click="generateTts('femail', line)"
+                                        />
+                                        <audio id="tts-audio-player" preload="auto"></audio>
+                                    </div>
                                     <p v-if="index % 2 !== 0" class="read mr40">{{ line }}</p>
                                     <div v-if="index % 2 !== 0" class="icon">
                                         <img src="../../../../resources/img/img37_s.png" alt="" />
@@ -139,6 +165,40 @@
             this.speakerA_name = speakers.speakerA_name;
             this.speakerB_name = speakers.speakerB_name;
         },
+
+        playAudio() {
+            const audio = document.getElementById('audio-player');
+            audio.play();
+            console.log('playing');
+        },
+
+        // 대화 지문 재생
+        generateTts(gender, line) {
+            console.log('line : ', line);
+            axios({
+                url: 'http://165.229.169.32:35716/generate_tts',
+                method: 'post',
+                headers: {
+                    'Content-Type': 'application/json; charset=UTF-8',
+                },
+                responseType: 'blob',
+                data: {
+                    gender: gender,
+                    input_text: line,
+                },
+            })
+                .then((response) => {
+                    console.log('tts 응답 : ', response);
+                    const audioBlob = new Blob([response.data], { type: 'audio/mpeg' });
+                    const audioUrl = URL.createObjectURL(audioBlob); // 오디오 url 생성
+                    const audioPlayer = document.getElementById('tts-audio-player');
+                    audioPlayer.src = audioUrl;
+                    audioPlayer.play();
+                })
+                .catch((err) => {
+                    console.log('tts 에러 : ', err);
+                });
+        },
     },
     watch: {},
     computed: {
Add a comment
List