Google Cloud Text to Speech Operators¶
Prerequisite Tasks¶
CloudTextToSpeechSynthesizeOperator¶
Synthesizes text to audio file and stores it to Google Cloud Storage
For parameter definition, take a look at
CloudTextToSpeechSynthesizeOperator
Arguments¶
The input
, voice
and audio_config
arguments need to be dicts or objects of corresponding classes from
google.cloud.texttospeech_v1.types
module
for more information, see: https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/api.html#google.cloud.texttospeech_v1.TextToSpeechClient.synthesize_speech
tests/system/providers/google/text_to_speech/example_text_to_speech.py
INPUT = {"text": "Sample text for demo purposes"}
VOICE = {"language_code": "en-US", "ssml_gender": "FEMALE"}
AUDIO_CONFIG = {"audio_encoding": "LINEAR16"}
The filename
argument is a simple string argument:
tests/system/providers/google/text_to_speech/example_text_to_speech.py
FILENAME = "gcp-speech-test-file"
Using the operator¶
tests/system/providers/google/text_to_speech/example_text_to_speech.py
text_to_speech_synthesize_task = CloudTextToSpeechSynthesizeOperator(
input_data=INPUT,
voice=VOICE,
audio_config=AUDIO_CONFIG,
target_bucket_name=BUCKET_NAME,
target_filename=FILENAME,
task_id="text_to_speech_synthesize_task",
)
Templating¶
template_fields: Sequence[str] = (
"input_data",
"voice",
"audio_config",
"project_id",
"gcp_conn_id",
"target_bucket_name",
"target_filename",
"impersonation_chain",
)