Skip to main content

Convert text to voice

Project description

Text to Audio SDK

PyPI Version Build Status Code Coverage Code Quality License

The Yandex Text to Audio SDK is a Python package that allows you to convert text to audio using Yandex premium voices. It provides an easy-to-use asynchronous interface for generating audio files from text with customizable voice, speed, and other parameters.

Installation

You can install the SDK from PyPI using pip:

pip install txt2voice

Quick Start

Here's a simple example demonstrating how to use the SDK to convert text to audio:

import asyncio

from txt2voice.api import TextToVoice, RequestParams
from txt2voice.models import VoiceParams, SpeedParams, AudioContent


async def main():
    token = 'YOUR_IAM_TOKEN'
    folder_id = 'YOUR_FOLDER_ID'
    text = 'Hello, this is an example text for audio conversion!'
    output_file = 'output_audio.mp3'

    api = TextToVoice(url='https://tts.api.cloud.yandex.net/speech/v1/tts:synthesize')

    convert_params = RequestParams(
        voice=VoiceParams(male='fillip', female='alyona'),
        speed=SpeedParams(speed=1.0),
        path_to_audiofiles=output_file,
        folder_id=folder_id,
        iam_token=token,
        lang='ru-RU',
        text=text
    )

    audio_content: AudioContent = await api.request_audio_content(convert_params)
    api.convert_ogg_to_mp3(audio_content, 'output_audio.mp3')


if __name__ == '__main__':
    asyncio.run(main())

Dependencies

The Yandex Text to Audio SDK has the following dependencies:

  • aiohttp
  • pydantic
  • pydub

You can install them using pip with the following command:

pip install aiohttp pydantic pydub

Contributing

Contributions to the project are welcome! If you find a bug, have a feature request, or want to contribute code, please open an issue or submit a pull request.

License

This SDK is licensed under the MIT License. See the LICENSE file for details.

Happy audio conversion with Yandex Text to Audio SDK!

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

txt2voice-0.1.2.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

txt2voice-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file txt2voice-0.1.2.tar.gz.

File metadata

  • Download URL: txt2voice-0.1.2.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for txt2voice-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fafdd7303d9ae1d5bed43f33ea80f611910fa3c0368b8c79a08193dfed6eb882
MD5 c3f110b5838151a9e46e2f66d2c9bc6e
BLAKE2b-256 58f894290421828f33296b674b74e6db734610345fa209604b6f231388edb16b

See more details on using hashes here.

File details

Details for the file txt2voice-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: txt2voice-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for txt2voice-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 808b6621db3543a13e65203de2c365840bea6c96206c2027f453a02f9e587505
MD5 f64af964c074763c25fcce1d2d757f41
BLAKE2b-256 a51201425ff893a8bced2c936920cfd531279d88b3d04e479a0d2b756f813fdc

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