Skip to main content

A package for text-to-speech and speech-to-text tools

Project description

TTS-STT Tools

tts-stt-tools is a Python package designed to facilitate seamless Text-to-Speech (TTS) and Speech-to-Text (STT) conversions. With customizable voice models and simple commands, it offers an easy way to convert text into audio and manage audio-to-text transcriptions.

Features

  • Text-to-Speech (TTS): Convert text into audio using various customizable voice models.
  • Speech-to-Text (STT): Transcribe audio files to text using speech recognition models.
  • Voice Model Support: Choose from a variety of pre-defined voice models for TTS.
  • File Management: Efficiently manage output files like .wav or .log for processing and cleanup.

Installation

Follow these steps to install the tts-stt-tools package and its dependencies:

Step 1: Create and activate a virtual environment

python3 -m venv testEnv1
source testEnv1/bin/activate

Step 2: Install the package

Inside the virtual environment, install the package:

python3 -m pip install --upgrade tts-stt-tools

Usage

The following sections demonstrate how to use both TTS and STT functionalities, including specifying models and handling output files.

Text-to-Speech (TTS)

Convert text to speech and save it as an audio file using different voice models.

Example 1: Using HiFi TTS (Low Quality)

from tts_stt_tools import process_text_to_speech

text = """
Part three

November 10–Present

CHAPTER 14
• Monday, November 10
On Monday morning, Maxine is startled...
"""
process_text_to_speech(text, voice_model='en_US/hifi-tts_low', filename='output1.wav')

Example 2: Using CMU Arctic (Low Quality)

process_text_to_speech(text, voice_model='en_US/cmu-arctic_low', filename='output2.wav')

Example 3: Using LJSpeech (Low Quality)

process_text_to_speech(text, voice_model='en_US/ljspeech_low', filename='output3.wav')

Example 4: Using M-AILABS (Low Quality)

process_text_to_speech(text, voice_model='en_US/m-ailabs_low', filename='output4.wav')

Example 5: Using VCTK (Low Quality)

process_text_to_speech(text, voice_model='en_US/vctk_low', filename='output5.wav')

Example 6: Using A-Pope (Low Quality)

process_text_to_speech(text, voice_model='en_UK/apope_low', filename='output6.wav')

Speech-to-Text (STT)

Convert a .wav audio file into text using the specified STT model.

Example 1: Using Vosk Model

from tts_stt_tools import process_speech_to_text

mp3_path = "output1.wav"
output_directory = ""  # Optional: specify if needed
model_path = "vosk-model-small-en-us-0.15"

result = process_speech_to_text(mp3_path, output_directory, model_path)
print(result)

Running Tests

Unit tests are included to ensure the correct behavior of TTS and STT processes. The tests create .wav files for various voice models, verifying that the output files exist after processing.

  1. Setup: The virtual environment is configured, and dependencies are installed.
  2. Testing: Each TTS model is validated to ensure audio files are generated.
  3. Cleanup: Resources like .wav files and temporary directories are removed after testing.

To run the tests, simply use:

pytest

The tests will:

  • Convert text into speech using different TTS voice models.
  • Convert audio files back into text using the Vosk STT model.

Cleanup After Testing

To clean up resources such as temporary files and directories after the tests, use:

deactivate
rm -r testEnv1
rm -r *.log *.wav
rm -r vosk-model-*

This updated documentation reflects the test cases and ensures users have a clear understanding of the TTS-STT workflow with examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tts-stt-tools-1.0.7.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tts_stt_tools-1.0.7-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file tts-stt-tools-1.0.7.tar.gz.

File metadata

  • Download URL: tts-stt-tools-1.0.7.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for tts-stt-tools-1.0.7.tar.gz
Algorithm Hash digest
SHA256 6e38130904c352389da098ade664aa64914b281b0e8a9724bcc90d0153692a50
MD5 5b537ff719a61bb2e43a02a344b0412a
BLAKE2b-256 f8a03ea811185fa0f4764079f78f9af729e5b7fccc8baf8d7aa5381a6edfb3f0

See more details on using hashes here.

File details

Details for the file tts_stt_tools-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: tts_stt_tools-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for tts_stt_tools-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7857b1c9b75bc83291190dbc4d97f13079567fb6524bd5492b04ea4eb92a0068
MD5 565274a7b718472b57d9f18dcd730d37
BLAKE2b-256 b2ac8c970f1147abdf20051cab188b3d45db3bb92957250fe207a3510e0d9c42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page