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.GoogleBaseHook
Google 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
- 返回类型: