diff --git a/Text-to-speech-coverter/Readme.md b/Text-to-speech-coverter/Readme.md new file mode 100644 index 0000000000..2bf8c8f53f --- /dev/null +++ b/Text-to-speech-coverter/Readme.md @@ -0,0 +1,33 @@ +# Text-to-Speech Conversion + +This Python program converts text input into speech using the Google Text-to-Speech (gTTS) library and plays the generated audio using the `playsound` library. + +## Requirements + +- Python 3.x +- See `requirements.txt` for the required libraries and versions. + +## Installation + +1. Clone the repository:https://github.com/emranpy/Amazing-Python-Scripts.git +2. Navigate to the project directory: cd Text-to-speech-converter +3. Install the required libraries: pip install -r requirements.txt + +## Usage + +1. Run the `text_to_speech.py` script: + +2. Enter the desired text when prompted. + +3. The program will convert the entered text to speech and save it as an MP3 file named `output.mp3`. + +4. The generated speech will be played automatically using the default audio player on your system. + +## Customization + +- You can modify the code to change the language or adjust the speech synthesis options by referring to the `gTTS` documentation. + +- To change the output filename, modify the `filename` variable in the code. + +- Feel free to incorporate the text-to-speech functionality into your own projects by importing the `text_to_speech` function. + diff --git a/Text-to-speech-coverter/output.mp3 b/Text-to-speech-coverter/output.mp3 new file mode 100644 index 0000000000..e6c565e4e6 Binary files /dev/null and b/Text-to-speech-coverter/output.mp3 differ diff --git a/Text-to-speech-coverter/requirements.txt b/Text-to-speech-coverter/requirements.txt new file mode 100644 index 0000000000..111452091a --- /dev/null +++ b/Text-to-speech-coverter/requirements.txt @@ -0,0 +1,2 @@ +gTTS==2.2.3 +playsound==1.2.2 \ No newline at end of file diff --git a/Text-to-speech-coverter/text_to_speech.py b/Text-to-speech-coverter/text_to_speech.py new file mode 100644 index 0000000000..1ece6d0d98 --- /dev/null +++ b/Text-to-speech-coverter/text_to_speech.py @@ -0,0 +1,19 @@ +from gtts import gTTS +from playsound import playsound + +# Function to convert text to speech +def text_to_speech(text, filename): + tts = gTTS(text=text, lang='en') + tts.save(filename) + +# Take input from the user +text = input("Enter your text: ") + +# Specify the output filename +filename = "output.mp3" + +# Convert text to speech +text_to_speech(text, filename) + +# Play the generated speech +playsound(filename) \ No newline at end of file

AltStyle によって変換されたページ (->オリジナル) /