diff --git a/src/evangelist/index.ts b/src/evangelist/index.ts index c5ff5ce..2a9e8b7 100644 --- a/src/evangelist/index.ts +++ b/src/evangelist/index.ts @@ -1,10 +1,12 @@ +import fs from "fs"; import { userRequest } from "../input.js"; import { logger } from "../utils/logger.js"; import { doTechEvangelistWork } from "./work.js"; -import fs from "fs"; +import { speak } from "../utils/speak.js"; export const doTechEvangelist = async () => { logger("테크 에반젤리스트에 의한 기획서 보충이 진행 중입니다..."); + await speak("테크 에반젤리스트에 의한 기획서 보충이 진행 중입니다..."); const resultFolderPath = "./result"; const resultFiles = await fs.promises.readdir(resultFolderPath); @@ -30,4 +32,5 @@ export const doTechEvangelist = async () => { `----USER REQUEST\n${userRequest}\n${evangelist}` ); logger("테크 에반젤리스트에 의한 기획서 보충이 완료되었습니다."); + await speak("테크 에반젤리스트에 의한 기획서 보충이 완료되었습니다."); }; diff --git a/src/utils/speak.ts b/src/utils/speak.ts index b75b9c4..1c300ce 100644 --- a/src/utils/speak.ts +++ b/src/utils/speak.ts @@ -4,20 +4,16 @@ import sound from "sound-play"; export const speak = async (text: string) => { try { - await new Promise((resolve, reject) => { + await new Promise((resolve) => { const audioFile = "./dist/_.wav"; - // This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION" const speechConfig = sdk.SpeechConfig.fromSubscription( process.env.AZURE_SPEECH_KEY, process.env.AZURE_SPEECH_REGION ); const audioConfig = sdk.AudioConfig.fromAudioFileOutput(audioFile); - - // The language of the voice that speaks. speechConfig.speechSynthesisVoiceName = process.env.AZURE_SPEECH_VOICE; - // Create the speech synthesizer. - var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig); + let synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig); synthesizer.speakTextAsync( text, @@ -29,7 +25,7 @@ export const speak = async (text: string) => { const absoultePath = fs.realpathSync(audioFile); await sound.play(absoultePath, 1); } else { - console.error( + throw new Error( "Speech synthesis canceled, " + result.errorDetails + "\nDid you set the speech resource key and region values?" @@ -37,7 +33,7 @@ export const speak = async (text: string) => { } resolve(); }, - function (err) { + (err) => { console.trace("err - " + err); synthesizer.close(); synthesizer = null;