Python uses text to speech

Request Sandbox
1from pathlib import Path
2from openai import OpenAI
3
4client = OpenAI(
5 base_url="https://api.AiApiGiaRe.io/v1",
6 api_key=key
7)
8
9speech_file_path = Path(__file__).parent / "speech.mp3"
10response = client.audio.speech.create(
11 model="tts-1",
12 voice="alloy",
13 input="Today is a wonderful day to build something people love!"
14)
15
16response.stream_to_file(speech_file_path)
Target: api.aiapigiare.io.vn
TLS 1.3 Active

Text-to-Speech (TTS) API Guide

Request Sandbox
1from pathlib import Path
2from openai import OpenAI
3
4client = OpenAI(
5 base_url="https://api.AiApiGiaRe.io/v1",
6 api_key=key
7)
8
9speech_file_path = Path(__file__).parent / "speech.mp3"
10response = client.audio.speech.create(
11 model="tts-1",
12 voice="alloy",
13 input="Today is a wonderful day to build something people love!"
14)
15
16response.stream_to_file(speech_file_path)
Target: api.aiapigiare.io.vn
TLS 1.3 Active

Overview

The Audio API provides the speech endpoint, powered by TTS models, to achieve the following functionalities:

  • 📝 Read blog articles aloud.
  • 🌍 Generate multilingual audio.
  • 🎵 Output real-time audio streams.

Important Note: You must inform users that the voice they hear is AI-generated and not a human voice.


Basic Usage

Basic Example

(Code extracted to sandbox)


Features

Audio Quality Options

  • tts-1: Low latency, suitable for real-time applications.
  • tts-1-hd: Higher quality, with potentially fewer static artifacts.

Available Voices

  • alloy
  • echo
  • fable
  • nova
  • shimmer
  • onyx

Supported Output Formats

FormatFeaturesUse Case
MP3Default formatGeneral-purpose scenarios
OpusLow latencyStreaming media and communication
AACEfficient compressionPlayback on mobile devices
FLACLossless compressionAudio archiving
WAVUncompressedLow-latency applications
PCMRaw sampling24kHz, 16-bit signed

Real-Time Audio Streaming

(Code extracted to sandbox)


Supported Languages

The API supports multiple languages, including:

  • Asian Languages: Chinese, Japanese, Korean, etc.
  • European Languages: English, French, German, etc.
  • Other Languages: Arabic, Hindi, etc.

Note: The current voices are primarily optimized for English.


Frequently Asked Questions (FAQs)

Q: How can I control the emotion of the generated audio?

A: There is currently no direct mechanism to control emotions. Capitalization or punctuation might influence the output, but the effect is not guaranteed.


Q: Can I create custom voices?

A: Custom voice creation is not supported at this time.


Q: Who owns the generated audio?

A: The audio belongs to the creator, but you must inform users that the audio is AI-generated.

Infrastructure: AiApiGiaRe-v10.0
Gateway Status: Operational