Інтеграція Google Cloud Text-to-Speech для синтезу мови Google Cloud TTS пропонує 380+ голосів 50+ мовами. Neural2 і Studio голоси – найнатуральніші в портфоліо Google. Wavenet-голоси мають відмінну якість за розумної вартості. Російською мовою: голоси ru-RU-Wavenet-A/B/C/D. ### Типи голосів | Тип | Якість | Вартість | приклад | |-----|---------|-----------|--------| | Standard | Базове | $4/1M chars | ru-RU-Standard-A | | Wavenet | Хороше | $16/1M chars | ru-RU-Wavenet-D | | Neural2 | Відмінне | $16/1M chars | ru-RU-Neural2-A | | Studio | Найкраще | $160/1M chars | ru-RU-Studio-* | ### Базова інтеграція
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
def synthesize(text: str, voice_name: str = "ru-RU-Wavenet-D") -> bytes:
synthesis_input = texttospeech.SynthesisInput(text=text)
voice = texttospeech.VoiceSelectionParams(
language_code="ru-RU",
name=voice_name,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3,
speaking_rate=1.0, # 0.25–4.0
pitch=0.0, # -20.0–20.0 полутонов
volume_gain_db=0.0, # -96.0–16.0 дБ
effects_profile_id=["telephony-class-application"] # для IVR
)
response = client.synthesize_speech(
input=synthesis_input,
voice=voice,
audio_config=audio_config
)
return response.audio_content
```### SSML для контролю інтонації```python
ssml_text = """
<speak>
Ваш заказ номер <say-as interpret-as="characters">A1234</say-as>
подтверждён на <say-as interpret-as="date" format="dd.MM.yyyy">01.03.2024</say-as>.
<break time="500ms"/>
Сумма к оплате: <say-as interpret-as="currency" language="ru-RU">1500 RUB</say-as>.
</speak>
"""
synthesis_input = texttospeech.SynthesisInput(ssml=ssml_text)
```Терміни: 1 день (базова інтеграція), 2-3 дні (з SSML та кешуванням).







