Freddy155 / text2speech-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLI Text-to-Speech Converter Documentation

This Python script allows you to convert text to speech and save it as an audio file. It utilizes the Google Text-to-Speech (gTTS) library for text-to-speech conversion and the 'mpg321' utility to play the audio.

Prerequisites

  • Python installed on your system (Python 3.x recommended)

  • The gtts library installed. You can install it using pip:

    pip install gtts

Certainly, I can provide you with a Markdown format documentation for the app.py script you provided. Here's a comprehensive guide:

markdownCopy code

`# Text-to-Speech Converter Documentation

This Python script allows you to convert text to speech and save it as an audio file. It utilizes the Google Text-to-Speech (gTTS) library for text-to-speech conversion and the 'mpg321' utility to play the audio.

Prerequisites

  • Python installed on your system (Python 3.x recommended)

  • The gtts library installed. You can install it using pip:

    pip install gtts
  • The 'mpg321' utility for playing the audio. You can install it depending on your operating system.

How to Use

  1. Download and save this app.py script to your local directory.

  2. Open your command line or terminal.

  3. Run the script using Python:

    python app.py
  4. Follow the prompts in the terminal to enter the necessary information:

    • Enter the text you want to convert to audio.
    • Enter the language code for the desired language (e.g., 'en' for English).
    • Enter the filename for the audio file (e.g., 'welcome.mp3').
  5. The script will convert the text to speech, save it as an audio file with the specified filename, and play the audio using 'mpg321'.

Example

Here's an example of how you can use the script:

  1. Run the script as mentioned earlier.

  2. Enter the following information as prompted:

    • Text to convert: "Welcome to geeksforgeeks!"
    • Language code: "en"
    • Filename for audio: "welcome.mp3"
  3. The script will create an audio file named "welcome.mp3" containing the converted speech and play it.

Notes

  • The 'mpg321' utility may not be available on all operating systems. You may need to install an alternative audio player if it's not supported.

  • Make sure to provide a valid language code for the desired language. You can refer to the gTTS supported languages for a list of available language codes.

  • Ensure that you have the necessary permissions to write and play audio files in your chosen directory.

About


Languages

Language:Python 100.0%