Google Cloud Speech Translate Operators¶
Prerequisite Tasks¶
CloudTranslateSpeechOperator¶
Recognizes speech in audio input and translates it.
For parameter definition, take a look at
CloudTranslateSpeechOperator
Arguments¶
Config and audio arguments need to be dicts or objects of corresponding classes from
google.cloud.speech_v1.types
module.
for more information, see: https://googleapis.github.io/google-cloud-python/latest/speech/gapic/v1/api.html#google.cloud.speech_v1.SpeechClient.recognize
Arguments for translation need to be specified.
CONFIG = {"encoding": "LINEAR16", "language_code": "en_US"}
AUDIO = {"uri": f"gs://{BUCKET_NAME}/{FILENAME}"}
TARGET_LANGUAGE = 'pl'
FORMAT = 'text'
MODEL = 'base'
SOURCE_LANGUAGE = None # type: None
Using the operator¶
translate_speech_task = CloudTranslateSpeechOperator(
project_id=GCP_PROJECT_ID,
audio=AUDIO,
config=CONFIG,
target_language=TARGET_LANGUAGE,
format_=FORMAT,
source_language=SOURCE_LANGUAGE,
model=MODEL,
task_id='translate_speech_task',
)
translate_speech_task2 = CloudTranslateSpeechOperator(
audio=AUDIO,
config=CONFIG,
target_language=TARGET_LANGUAGE,
format_=FORMAT,
source_language=SOURCE_LANGUAGE,
model=MODEL,
task_id='translate_speech_task2',
)
Templating¶
template_fields = (
'target_language',
'format_',
'source_language',
'model',
'project_id',
'gcp_conn_id',
'impersonation_chain',
)