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:

pip install --editable .

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.6.tar.gz (9.1 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.6-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tts-stt-tools-1.0.6.tar.gz
  • Upload date:
  • Size: 9.1 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.6.tar.gz
Algorithm Hash digest
SHA256 33a833a4ac151232e1b0dc15f76d91bdddcc89c42ddc0262f81d43e651480750
MD5 ba2908874e3a66629a045b7a3cd566bc
BLAKE2b-256 f12d9892175b6774f1b634c293dc2e462eb4c951d37acf2d32463282d773302f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tts_stt_tools-1.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 48892d683526cf602fc756e29ba1bbdc7237d58b0ad8ebc6a9da3039092381b8
MD5 1e8737e5d9a24f70e38becb14aa11b88
BLAKE2b-256 1366475afe893ed85a979f3aac5244a84dabf3062ea960f785910beb831254e9

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