aboutsummaryrefslogtreecommitdiff
path: root/autogpts/autogpt/autogpt/speech/gtts.py
diff options
context:
space:
mode:
Diffstat (limited to 'autogpts/autogpt/autogpt/speech/gtts.py')
-rw-r--r--autogpts/autogpt/autogpt/speech/gtts.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/autogpts/autogpt/autogpt/speech/gtts.py b/autogpts/autogpt/autogpt/speech/gtts.py
new file mode 100644
index 000000000..40f7bcb97
--- /dev/null
+++ b/autogpts/autogpt/autogpt/speech/gtts.py
@@ -0,0 +1,24 @@
+""" GTTS Voice. """
+from __future__ import annotations
+
+import os
+
+import gtts
+from playsound import playsound
+
+from autogpt.speech.base import VoiceBase
+
+
+class GTTSVoice(VoiceBase):
+ """GTTS Voice."""
+
+ def _setup(self) -> None:
+ pass
+
+ def _speech(self, text: str, _: int = 0) -> bool:
+ """Play the given text."""
+ tts = gtts.gTTS(text)
+ tts.save("speech.mp3")
+ playsound("speech.mp3", True)
+ os.remove("speech.mp3")
+ return True