We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4cccb71 commit 03280c0Copy full SHA for 03280c0
voice.py
@@ -1,14 +1,18 @@
1
from gtts import gTTS
2
+from colorama import Fore
3
import os
4
5
# Define the text you want to convert to speech
6
text = "Hello! This is a sample text to convert to speech."
7
-# Create a gTTS object
8
-tts = gTTS(text=text, lang="en")
+try:
9
+ # Create a gTTS object
10
+ tts = gTTS(text=text, lang="en")
11
-# Save the audio file
-tts.save("output.mp3")
12
+ # Save the audio file
13
+ tts.save("output.mp3")
14
-# Play the audio file
-os.system("start output.mp3")
15
+ # Play the audio file
16
+ os.system("start output.mp3")
17
+except Exception as e:
18
+ print(Fore.RED, e, Fore.RESET)
0 commit comments