Skip to content

Commit

Permalink
fix: add detailed logging and handle undefined ChatGPT response
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name (aider) committed Sep 26, 2024
1 parent 353c400 commit 8d94a4a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions discordChatGPTVoiceBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ function saveTextStream(textToSpeak, callback) {
return;
}

console.log("Starting speech synthesis for text:", textToSpeak);

const speechConfig = sdk.SpeechConfig.fromSubscription(SPEECH_KEY, "eastus");
speechConfig.speechSynthesisLanguage = VOICE_LANGUAGE;
speechConfig.speechSynthesisVoiceName = VOICE_FEMALE;
Expand All @@ -87,6 +89,7 @@ function saveTextStream(textToSpeak, callback) {
textToSpeak,
result => {
if (result) {
console.log("Speech synthesis completed successfully");
const stream = new PassThrough();
stream.end(Buffer.from(result.audioData));
callback(stream);
Expand Down Expand Up @@ -136,6 +139,7 @@ async function chatgpt(message, msg) {

if (response && response.response) {
if (typeof response.response === 'string') {
console.log("ChatGPT response to be spoken:", response.response);
saveTextStream(response.response, audiohandler);

if (msg && msg.channel) {
Expand Down

0 comments on commit 8d94a4a

Please sign in to comment.