Skip to main content

TTS extension for multiai using OpenAI, Google GenAI and Azure Speech

Project description

multiai-tts

multiai-tts is an extension library for multiai that provides Text-to-Speech (TTS) capabilities using OpenAI, Google GenAI, and Azure Speech.

Prerequisites

API Key Configuration

This library relies on the configuration provided by multiai. You must set up your API keys (OpenAI API Key, Google API Key, Azure TTS Key and Region) using multiai's configuration files or environment variables before using this library.

For details on how to configure API keys, please refer to the multiai documentation.

System Requirements

  • ffmpeg must be installed if you want to save audio in formats other than WAV (e.g., MP3).
  • pydub is required for audio conversion.

Installation

pip install multiai-tts

Usage

Google GenAI Example

import sys
import multiai_tts

client = multiai_tts.Prompt()
client.set_tts_model('google', 'gemini-2.5-flash-preview-tts')
client.tts_voice_google = 'charon'

# Speak directly
client.speak("Please speak the following. Hello, this is a test from Google model.")
if client.error:
    print(client.error_message)
    sys.exit(1)

# Save to file
client.save_tts("Please speak the following. Saving this audio to mp3.", "output_google.mp3")
if client.error:
    print(client.error_message)
    sys.exit(1)

OpenAI Example

import sys
import multiai_tts

client = multiai_tts.Prompt()
client.set_tts_model('openai', 'gpt-4o-mini-tts')
client.tts_voice_openai = 'marin'

# Speak directly
client.speak("Hello, this is a test from OpenAI model.")
if client.error:
    print(client.error_message)
    sys.exit(1)

# Save to file
client.save_tts("Saving this audio to mp3.", "output_openai.mp3")
if client.error:
    print(client.error_message)
    sys.exit(1)

Azure TTS Example

import sys
import multiai_tts

client = multiai_tts.Prompt()
client.set_tts_provider('azure')
client.tts_voice_azure = 'en-US-JennyNeural'

# Speak directly
client.speak("Hello, this is a test from Azure TTS.")
if client.error:
    print(client.error_message)
    sys.exit(1)

# Save to file
client.save_tts("Saving this audio to mp3.", "output_azure.mp3")
if client.error:
    print(client.error_message)
    sys.exit(1)

Notes

  • For OpenAI and Google TTS, use set_tts_model(provider, model) to select both provider and model.
  • For Azure, set_tts_provider('azure') is sufficient; the model parameter is not used.
  • In Google’s example, the prompt includes “Please speak the following.” In the OpenAI and Azure examples, it does not. Whether you include this phrase depends on the model you use.
  • Prompt.get_wav() fetches the raw audio data in memory. Playback is separate from retrieval.
  • Error handling: After speak() or save_tts(), always check client.error and client.error_message.
  • WAV output is default; use pydub/ffmpeg for other formats.

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

multiai_tts-0.2.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

multiai_tts-0.2.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file multiai_tts-0.2.1.tar.gz.

File metadata

  • Download URL: multiai_tts-0.2.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for multiai_tts-0.2.1.tar.gz
Algorithm Hash digest
SHA256 15304e2be75bd17abb2d76c0a0811d4683639d5cbff6056d1c9bbb08cde065ae
MD5 324a3956ba1ffa412f15dc44d7037896
BLAKE2b-256 cbbffafcac7d747f8c0472b691bf9b72ee3671fc6f2a2dc888d5f2760d8aa275

See more details on using hashes here.

File details

Details for the file multiai_tts-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: multiai_tts-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for multiai_tts-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7472e6d1447f9a43f92472a50174bf44b576b88b5fa3457f6b42ce6a5890f3ca
MD5 c69978e8ef99533e0e5148d1985f9aad
BLAKE2b-256 c3497f235636875b6aaa10b244118fed1c96667f5819b8fb24682376acc245d9

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