diff --git a/.env-example b/.env-example index 81ba383..7f8acc1 100644 --- a/.env-example +++ b/.env-example @@ -81,6 +81,10 @@ TRANSCRIPTION_LANGUAGE= # It's open source: https://github.com/askrella/speech-rest-api TTS_ENABLED=false +# Defines if the bot should return the TTS response as a text message too +# If enabled, the bot will send the text response and the voice message +TTS_TRANSCRIPTION_RESPONSE_ENABLED=true + # Defines if the bot should use the Speech API or AWS Polly to convert text to speech # "speech-api" = It will use our Speech API to transcribe your voice messages # "aws-polly" = It will use AWS Polly to convert text to speech diff --git a/docs/pages/tts.md b/docs/pages/tts.md index 8a5d173..09e0ce8 100644 --- a/docs/pages/tts.md +++ b/docs/pages/tts.md @@ -8,6 +8,14 @@ You can enable it by setting the following environment variable: TTS_ENABLED=true ``` +By default, when TTS is enabled, the bot will answer two messages: the text response and the audio response. + +You can disable the text response by changing the following environment variable: + +```bash +TTS_TRANSCRIPTION_RESPONSE_ENABLED=true +``` + ## Supported Providers - [Speech API](#speech-api) diff --git a/src/config.ts b/src/config.ts index 24fa369..3356926 100644 --- a/src/config.ts +++ b/src/config.ts @@ -50,6 +50,7 @@ interface IConfig { whisperApiKey: string; ttsEnabled: boolean; ttsMode: TTSMode; + ttsTranscriptionResponse: boolean; transcriptionEnabled: boolean; transcriptionMode: TranscriptionMode; transcriptionLanguage: string; @@ -98,6 +99,7 @@ export const config: IConfig = { // Text-to-Speech ttsEnabled: getEnvBooleanWithDefault("TTS_ENABLED", false), // Default: false ttsMode: getEnvTTSMode(), // Default: speech-api + ttsTranscriptionResponse: getEnvBooleanWithDefault("TTS_TRANSCRIPTION_RESPONSE_ENABLED", true), // Default: true // Transcription transcriptionEnabled: getEnvBooleanWithDefault("TRANSCRIPTION_ENABLED", false), // Default: false diff --git a/src/handlers/message.ts b/src/handlers/message.ts index c645c77..614054b 100644 --- a/src/handlers/message.ts +++ b/src/handlers/message.ts @@ -112,8 +112,10 @@ async function handleIncomingMessage(message: Message) { cli.print(`[Transcription] Transcription response: ${transcribedText} (language: ${transcribedLanguage})`); // Reply with transcription - const reply = `You said: ${transcribedText}${transcribedLanguage ? " (language: " + transcribedLanguage + ")" : ""}`; - message.reply(reply); + if (config.ttsTranscriptionResponse) { + const reply = `You said: ${transcribedText}${transcribedLanguage ? " (language: " + transcribedLanguage + ")" : ""}`; + message.reply(reply); + } // Handle message GPT await handleMessageGPT(message, transcribedText);