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.
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:
- Whisper by OpenAI for speech recognition: Whisper GitHub Repository
- Helsinki-NLP's MarianMT for text translation: MarianMT GitHub Repository
- Silero Models for speech synthesis: Silero Models GitHub Repository
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.
Metadata
Release files for babylon-sts 0.1.43
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| babylon_sts-0.1.43.tar.gz | 7.1 kB | Without provenance | Details for babylon_sts-0.1.43.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| babylon_sts-0.1.43-py3-none-any.whl | Python 3 | none | any | Details for babylon_sts-0.1.43-py3-none-any.whl |
Total release size: 13.8 kB
Release files / babylon_sts-0.1.43.tar.gz
| Download URL | babylon_sts-0.1.43.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b2c23e4593d01ba495943faf31424c339f74247fa5533314b1020af2d553163
|
|
BLAKE2b-256 checksum How to use checksums |
e90869c77218f355f710ed5cd2fa1eb36689fa564911a38deb482bf4ed9b826b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.9
|
Release files / babylon_sts-0.1.43-py3-none-any.whl
| Download URL | babylon_sts-0.1.43-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c14afd4c5c14e80e5ecc57276eeeaf63b464d35a61eba3be31f85ecc86a0ac9d
|
|
BLAKE2b-256 checksum How to use checksums |
1b3cb4c899da63cb95ed24297a2c6d0cce485281fe42736a212825fc87a7205a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.9
|
Security for babylon-sts 0.1.43
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.