airflow.providers.google.cloud.hooks.text_to_speech¶
此模組包含一個 Google Cloud Text to Speech Hook。
類¶
Google Cloud Text to Speech API 的 Hook。 |
模組內容¶
- class airflow.providers.google.cloud.hooks.text_to_speech.CloudTextToSpeechHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]¶
基類:
airflow.providers.google.common.hooks.base_google.GoogleBaseHookGoogle Cloud Text to Speech API 的 Hook。
Hook 中所有使用 project_id 的方法都必須使用關鍵字引數呼叫,而非位置引數。
- 引數:
gcp_conn_id (str) – 獲取連線資訊時使用的連線 ID。
impersonation_chain (str | collections.abc.Sequence[str] | None) – 可選的服務賬號,用於使用短期憑證進行模擬,或獲取列表中最後一個賬號的 access_token 所需的賬號鏈,該賬號將在請求中被模擬。如果設定為字串,該賬號必須授予發起賬號 Service Account Token Creator IAM 角色。如果設定為序列,列表中的身份必須授予直接前一個身份 Service Account Token Creator IAM 角色,列表中第一個賬號授予發起賬號此角色。
- get_conn()[source]¶
檢索與 Cloud Text to Speech 的連線。
- 返回:
Google Cloud Text to Speech 客戶端物件。
- 返回型別:
google.cloud.texttospeech_v1.TextToSpeechClient
- synthesize_speech(input_data, voice, audio_config, retry=DEFAULT, timeout=None)[source]¶
合成文字輸入。
- 引數:
input_data (dict | google.cloud.texttospeech_v1.types.SynthesisInput) – 要合成的文字輸入。詳情見: https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/types.html#google.cloud.texttospeech_v1.types.SynthesisInput
voice (dict | google.cloud.texttospeech_v1.types.VoiceSelectionParams) – 合成中使用的語音配置。詳情見: https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/types.html#google.cloud.texttospeech_v1.types.VoiceSelectionParams
audio_config (dict | google.cloud.texttospeech_v1.types.AudioConfig) – 合成音訊的配置。詳情見: https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/types.html#google.cloud.texttospeech_v1.types.AudioConfig
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – (可選)用於重試請求的重試物件。如果指定為 None,則請求不會被重試。
timeout (float | None) – (可選)等待請求完成的時間量,單位為秒。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
- 返回:
SynthesizeSpeechResponse 詳情見: https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/types.html#google.cloud.texttospeech_v1.types.SynthesizeSpeechResponse
- 返回型別: