Skip to main content

A powerful library for audio processing with advanced features for speech recognition, text translation, and speech synthesis.

Project description

Babylon STS

A powerful library for audio processing with advanced features for speech recognition, text translation, and speech synthesis.

This robust library offers a wide range of capabilities for working with audio, including speech recognition, text translation, and speech synthesis. It is perfect for developers looking to integrate advanced audio features into their applications.

Key Features:

  • Speech Recognition: Accurate and fast conversion of voice to text for various languages.
  • Text Translation: Automatic translation of recognized text into other languages, making interaction more accessible.
  • Speech Synthesis: Generation of natural-sounding speech from text, enabling the creation of interactive voice applications.

This library is designed to provide high-quality audio processing tools, offering everything you need to develop innovative solutions in the field of speech technology.

Flowchart of process_audio

Installation

pip install babylon-sts

Usage examples

Processing a Local Audio File

Here is an example of how to process a local audio file, translate its content, and save the result to a new file:

import numpy as np
import soundfile as sf
from datetime import datetime
from pydub import AudioSegment
from babylon_sts import AudioProcessor

def process_local_audio(input_file: str, output_file: str, language_to: str = 'ru', language_from: str = 'en', model_name: str = 'small', sample_rate: int = 24000):
    # Using pydub to read the MP3 file
    audio_segment = AudioSegment.from_file(input_file)

    # Converting audio to a format supported for further processing
    audio_segment = audio_segment.set_frame_rate(sample_rate).set_channels(1)
    audio_data = np.array(audio_segment.get_array_of_samples())
    audio_data = audio_data.tobytes()  # Converting data to bytes

    # Creating an instance of AudioProcessor with the necessary parameters
    audio_processor = AudioProcessor(language_to=language_to, language_from=language_from, model_name=model_name, sample_rate=sample_rate)

    # Current time as a timestamp for processing
    timestamp = datetime.utcnow()

    try:
        # Processing the audio data
        final_audio, log_data = audio_processor.process_audio(timestamp, audio_data)

        # Saving the processed audio to a new file
        sf.write(output_file, final_audio, sample_rate)
    except ValueError as e:
        print(f"Error during synthesis: {e}")

# Calling the function to process the local file
process_local_audio('audio/original_audio.mp3', 'audio/translated_audio.wav')

AudioProcessor args:

  • language_to (str): The language code. Possible values: 'en', 'ua', 'ru', 'fr', 'de', 'es', 'hi'.
  • language_from (str): The language code. Possible values: 'en', 'ua', 'ru', 'fr', 'de', 'es', 'hi'.
  • model_name (str): The Whisper model to use. Possible values: 'tiny', 'base', 'small', 'medium', 'large'.
  • sample_rate (int): The sample rate for audio processing.
  • speaker (Optional[str]): The name of speaker for speech synthesize. Full speakers list here https://github.com/snakers4/silero-models?tab=readme-ov-file#models-and-speakers

Install requirements

pip install -r requirements.txt

Tests

python -m unittest discover -s tests

Acknowledgments

This library leverages several state-of-the-art models to provide advanced audio processing features:

These models are used in accordance with their respective licenses.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

babylon_sts-0.1.42.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

babylon_sts-0.1.42-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file babylon_sts-0.1.42.tar.gz.

File metadata

  • Download URL: babylon_sts-0.1.42.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.9

File hashes

Hashes for babylon_sts-0.1.42.tar.gz
Algorithm Hash digest
SHA256 cc68c9e9e417a93306f11769887793ac0a34515f339e5692dd1239ec669bb059
MD5 f025521bce6d770fed44bb3163e92b1b
BLAKE2b-256 0ada837685e57d56b8a17abee9b893cba2b467a6dc40fbe46cfd6c918ee7c90e

See more details on using hashes here.

File details

Details for the file babylon_sts-0.1.42-py3-none-any.whl.

File metadata

File hashes

Hashes for babylon_sts-0.1.42-py3-none-any.whl
Algorithm Hash digest
SHA256 94250904bd31369d01a450255aea8fbbcc3c49d18498f4a6748ba7fb37f3b215
MD5 6e0e00a94dc26d8b3b6cab3b389f6c25
BLAKE2b-256 e7bc6083ddb2714e4e49157b46214b71d7191ec8a1b7eec9b3eb3fd3b0645ce7

See more details on using hashes here.

Supported by

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