IT/3D Web

Google TTS

루벤초이 2021. 5. 27. 17:09

 
 
Text-to-Speech 활성화

검색
사용

Node 앱
설치부터

#npm i --save @google-cloud/text-to-speech

수정사항

const start = (client) => {
    ...중략...
    client.on('tts', (text) => {
        console.log("---TTS Audio Data from Text Requested: ", text);
        getAudioBufferFromText(text).then((results) => {
            console.log("results: ", results);
            client.emit('ttsResult', results);
        }).catch((err) => console.log("error: ", err));
    })
}


async function getAudioBufferFromText(text) {
    console.log("getAudioBufferFromText");
    const requestTTS = {
        voice: {
            languageCode: languageCode,
            ssmlGender: 'NEUTRAL'
        },
        audioConfig: {
            audioEncoding: encoding
        }
    }
    requestTTS.input = { text: text };
    const response = await ttsClient.synthesizeSpeech(requestTTS);
    return response[0].audioContent;
}

 
실행

주어진 텍스트에 대한 TTS Audio Data

 
Dialogflow outputAudioConfig
 
 

728x90
반응형