[AIRFLOW-6126] [AIP-21] Rename GCP Speech operators (#6827)
Also these modules have been changed GcpTextToSpeechSynthesizeOperator, GCPSpeechToTextHook, GCPTextToSpeechHook
This commit is contained in:
Родитель
003da9b29a
Коммит
1d5b850c8b
|
@ -333,7 +333,6 @@ The following table shows changes in import paths.
|
|||
|airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook |airflow.providers.google.cloud.hooks.pubsub.PubSubHook |
|
||||
|airflow.contrib.hooks.gcp_speech_to_text_hook.GCPSpeechToTextHook |airflow.gcp.hooks.speech_to_text.CloudSpeechToTextHook |
|
||||
|airflow.contrib.hooks.gcp_spanner_hook.CloudSpannerHook |airflow.gcp.hooks.spanner.SpannerHook |
|
||||
|airflow.contrib.hooks.gcp_speech_to_text_hook.GCPSpeechToTextHook |airflow.gcp.hooks.speech_to_text.GCPSpeechToTextHook |
|
||||
|airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook |airflow.gcp.hooks.cloud_sql.CloudSqlDatabaseHook |
|
||||
|airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook |airflow.gcp.hooks.cloud_sql.CloudSqlHook |
|
||||
|airflow.contrib.hooks.gcp_tasks_hook.CloudTasksHook |airflow.gcp.hooks.tasks.CloudTasksHook |
|
||||
|
@ -434,8 +433,8 @@ The following table shows changes in import paths.
|
|||
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseUpdateOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDatabaseUpdateOperator |
|
||||
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeleteOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDeleteOperator |
|
||||
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeployOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDeployOperator |
|
||||
|airflow.contrib.operators.gcp_speech_to_text_operator.GcpSpeechToTextRecognizeSpeechOperator |airflow.gcp.operators.speech_to_text.GcpSpeechToTextRecognizeSpeechOperator |
|
||||
|airflow.contrib.operators.gcp_text_to_speech_operator.GcpTextToSpeechSynthesizeOperator |airflow.gcp.operators.text_to_speech.GcpTextToSpeechSynthesizeOperator |
|
||||
|airflow.contrib.operators.gcp_speech_to_text_operator.GcpSpeechToTextRecognizeSpeechOperator |airflow.gcp.operators.speech_to_text.CloudSpeechToTextRecognizeSpeechOperator
|
||||
|airflow.contrib.operators.gcp_text_to_speech_operator.GcpTextToSpeechSynthesizeOperator |airflow.gcp.operators.text_to_speech.CloudTextToSpeechSynthesizeOperator |
|
||||
|airflow.contrib.operators.gcp_transfer_operator.GcpTransferServiceJobCreateOperator |airflow.gcp.operators.cloud_storage_transfer_service.GcpTransferServiceJobCreateOperator |
|
||||
|airflow.contrib.operators.gcp_transfer_operator.GcpTransferServiceJobDeleteOperator |airflow.gcp.operators.cloud_storage_transfer_service.GcpTransferServiceJobDeleteOperator |
|
||||
|airflow.contrib.operators.gcp_transfer_operator.GcpTransferServiceJobUpdateOperator |airflow.gcp.operators.cloud_storage_transfer_service.GcpTransferServiceJobUpdateOperator |
|
||||
|
|
|
@ -22,8 +22,7 @@ This module is deprecated. Please use `airflow.gcp.hooks.text_to_speech`.
|
|||
|
||||
import warnings
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from airflow.gcp.hooks.text_to_speech import CloudTextToSpeechHook # noqa
|
||||
from airflow.gcp.hooks.text_to_speech import CloudTextToSpeechHook
|
||||
|
||||
warnings.warn(
|
||||
"This module is deprecated. Please use `airflow.gcp.hooks.text_to_speech`",
|
||||
|
|
|
@ -22,10 +22,24 @@ This module is deprecated. Please use `airflow.gcp.operators.speech_to_text`.
|
|||
|
||||
import warnings
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from airflow.gcp.operators.speech_to_text import GcpSpeechToTextRecognizeSpeechOperator # noqa
|
||||
from airflow.gcp.operators.speech_to_text import CloudSpeechToTextRecognizeSpeechOperator
|
||||
|
||||
warnings.warn(
|
||||
"This module is deprecated. Please use `airflow.gcp.operators.speech_to_text`",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
|
||||
class GcpSpeechToTextRecognizeSpeechOperator(CloudSpeechToTextRecognizeSpeechOperator):
|
||||
"""
|
||||
This class is deprecated.
|
||||
Please use `airflow.gcp.operators.speech_to_text.CloudSpeechToTextRecognizeSpeechOperator`.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
"""This class is deprecated.
|
||||
Please use `airflow.gcp.operators.speech_to_text.CloudSpeechToTextRecognizeSpeechOperator`.""",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -22,10 +22,24 @@ This module is deprecated. Please use `airflow.gcp.operators.text_to_speech`.
|
|||
|
||||
import warnings
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from airflow.gcp.operators.text_to_speech import GcpTextToSpeechSynthesizeOperator # noqa
|
||||
from airflow.gcp.operators.text_to_speech import CloudTextToSpeechSynthesizeOperator
|
||||
|
||||
warnings.warn(
|
||||
"This module is deprecated. Please use `airflow.gcp.operators.text_to_speech`",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
|
||||
class GcpTextToSpeechSynthesizeOperator(CloudTextToSpeechSynthesizeOperator):
|
||||
"""
|
||||
This class is deprecated.
|
||||
Please use `airflow.gcp.operators.text_to_speech.CloudTextToSpeechSynthesizeOperator`.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
"""This class is deprecated.
|
||||
Please use `airflow.gcp.operators.text_to_speech.CloudTextToSpeechSynthesizeOperator`.""",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -28,8 +28,8 @@ This DAG relies on the following OS environment variables
|
|||
import os
|
||||
|
||||
from airflow import models
|
||||
from airflow.gcp.operators.speech_to_text import GcpSpeechToTextRecognizeSpeechOperator
|
||||
from airflow.gcp.operators.text_to_speech import GcpTextToSpeechSynthesizeOperator
|
||||
from airflow.gcp.operators.speech_to_text import CloudSpeechToTextRecognizeSpeechOperator
|
||||
from airflow.gcp.operators.text_to_speech import CloudTextToSpeechSynthesizeOperator
|
||||
from airflow.gcp.operators.translate_speech import GcpTranslateSpeechOperator
|
||||
from airflow.utils import dates
|
||||
|
||||
|
@ -67,7 +67,7 @@ with models.DAG(
|
|||
) as dag:
|
||||
|
||||
# [START howto_operator_text_to_speech_synthesize]
|
||||
text_to_speech_synthesize_task = GcpTextToSpeechSynthesizeOperator(
|
||||
text_to_speech_synthesize_task = CloudTextToSpeechSynthesizeOperator(
|
||||
project_id=GCP_PROJECT_ID,
|
||||
input_data=INPUT,
|
||||
voice=VOICE,
|
||||
|
@ -79,7 +79,7 @@ with models.DAG(
|
|||
# [END howto_operator_text_to_speech_synthesize]
|
||||
|
||||
# [START howto_operator_speech_to_text_recognize]
|
||||
speech_to_text_recognize_task = GcpSpeechToTextRecognizeSpeechOperator(
|
||||
speech_to_text_recognize_task = CloudSpeechToTextRecognizeSpeechOperator(
|
||||
project_id=GCP_PROJECT_ID, config=CONFIG, audio=AUDIO, task_id="speech_to_text_recognize_task"
|
||||
)
|
||||
# [END howto_operator_speech_to_text_recognize]
|
||||
|
|
|
@ -30,13 +30,13 @@ from airflow.models import BaseOperator
|
|||
from airflow.utils.decorators import apply_defaults
|
||||
|
||||
|
||||
class GcpSpeechToTextRecognizeSpeechOperator(BaseOperator):
|
||||
class CloudSpeechToTextRecognizeSpeechOperator(BaseOperator):
|
||||
"""
|
||||
Recognizes speech from audio file and returns it as text.
|
||||
|
||||
.. seealso::
|
||||
For more information on how to use this operator, take a look at the guide:
|
||||
:ref:`howto/operator:GcpSpeechToTextRecognizeSpeechOperator`
|
||||
:ref:`howto/operator:CloudSpeechToTextRecognizeSpeechOperator`
|
||||
|
||||
:param config: information to the recognizer that specifies how to process the request. See more:
|
||||
https://googleapis.github.io/google-cloud-python/latest/speech/gapic/v1/types.html#google.cloud.speech_v1.types.RecognitionConfig
|
||||
|
|
|
@ -33,7 +33,7 @@ from airflow.models import BaseOperator
|
|||
from airflow.utils.decorators import apply_defaults
|
||||
|
||||
|
||||
class GcpTextToSpeechSynthesizeOperator(BaseOperator):
|
||||
class CloudTextToSpeechSynthesizeOperator(BaseOperator):
|
||||
"""
|
||||
Synthesizes text to speech and stores it in Google Cloud Storage
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class GcpTranslateSpeechOperator(BaseOperator):
|
|||
|
||||
Note that it uses the first result from the recognition api response - the one with the highest confidence
|
||||
In order to see other possible results please use
|
||||
:ref:`howto/operator:GcpSpeechToTextRecognizeSpeechOperator`
|
||||
:ref:`howto/operator:CloudSpeechToTextRecognizeSpeechOperator`
|
||||
and
|
||||
:ref:`howto/operator:CloudTranslateTextOperator`
|
||||
separately
|
||||
|
|
|
@ -83,15 +83,15 @@ Templating
|
|||
Google Cloud Speech to Text Operators
|
||||
=====================================
|
||||
|
||||
.. _howto/operator:GcpSpeechToTextRecognizeSpeechOperator:
|
||||
.. _howto/operator:CloudSpeechToTextRecognizeSpeechOperator:
|
||||
|
||||
GcpSpeechToTextRecognizeSpeechOperator
|
||||
--------------------------------------
|
||||
CloudSpeechToTextRecognizeSpeechOperator
|
||||
----------------------------------------
|
||||
|
||||
Recognizes speech in audio input and returns text.
|
||||
|
||||
For parameter definition, take a look at
|
||||
:class:`airflow.gcp.operators.speech_to_text.GcpSpeechToTextRecognizeSpeechOperator`
|
||||
:class:`airflow.gcp.operators.speech_to_text.CloudSpeechToTextRecognizeSpeechOperator`
|
||||
|
||||
Arguments
|
||||
"""""""""
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import unittest
|
||||
|
||||
from airflow import AirflowException
|
||||
from airflow.gcp.operators.speech_to_text import GcpSpeechToTextRecognizeSpeechOperator
|
||||
from airflow.gcp.operators.speech_to_text import CloudSpeechToTextRecognizeSpeechOperator
|
||||
from tests.compat import Mock, patch
|
||||
|
||||
PROJECT_ID = "project-id"
|
||||
|
@ -34,7 +34,7 @@ class TestCloudSql(unittest.TestCase):
|
|||
def test_recognize_speech_green_path(self, mock_hook):
|
||||
mock_hook.return_value.recognize_speech.return_value = True
|
||||
|
||||
GcpSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
CloudSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
project_id=PROJECT_ID, gcp_conn_id=GCP_CONN_ID, config=CONFIG, audio=AUDIO, task_id="id"
|
||||
).execute(context={"task_instance": Mock()})
|
||||
|
||||
|
@ -48,7 +48,7 @@ class TestCloudSql(unittest.TestCase):
|
|||
mock_hook.return_value.recognize_speech.return_value = True
|
||||
|
||||
with self.assertRaises(AirflowException) as e:
|
||||
GcpSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
CloudSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
project_id=PROJECT_ID, gcp_conn_id=GCP_CONN_ID, audio=AUDIO, task_id="id"
|
||||
).execute(context={"task_instance": Mock()})
|
||||
|
||||
|
@ -61,7 +61,7 @@ class TestCloudSql(unittest.TestCase):
|
|||
mock_hook.return_value.recognize_speech.return_value = True
|
||||
|
||||
with self.assertRaises(AirflowException) as e:
|
||||
GcpSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
CloudSpeechToTextRecognizeSpeechOperator( # pylint: disable=no-value-for-parameter
|
||||
project_id=PROJECT_ID, gcp_conn_id=GCP_CONN_ID, config=CONFIG, task_id="id"
|
||||
).execute(context={"task_instance": Mock()})
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import unittest
|
|||
from parameterized import parameterized
|
||||
|
||||
from airflow import AirflowException
|
||||
from airflow.gcp.operators.text_to_speech import GcpTextToSpeechSynthesizeOperator
|
||||
from airflow.gcp.operators.text_to_speech import CloudTextToSpeechSynthesizeOperator
|
||||
from tests.compat import ANY, Mock, PropertyMock, patch
|
||||
|
||||
PROJECT_ID = "project-id"
|
||||
|
@ -44,7 +44,7 @@ class TestGcpTextToSpeech(unittest.TestCase):
|
|||
mock_text_to_speech_hook.return_value.synthesize_speech.return_value = mocked_response
|
||||
mock_gcp_hook.return_value.upload.return_value = True
|
||||
|
||||
GcpTextToSpeechSynthesizeOperator(
|
||||
CloudTextToSpeechSynthesizeOperator(
|
||||
project_id=PROJECT_ID,
|
||||
gcp_conn_id=GCP_CONN_ID,
|
||||
input_data=INPUT,
|
||||
|
@ -87,7 +87,7 @@ class TestGcpTextToSpeech(unittest.TestCase):
|
|||
mock_gcp_hook,
|
||||
):
|
||||
with self.assertRaises(AirflowException) as e:
|
||||
GcpTextToSpeechSynthesizeOperator(
|
||||
CloudTextToSpeechSynthesizeOperator(
|
||||
project_id="project-id",
|
||||
input_data=input_data,
|
||||
voice=voice,
|
||||
|
|
|
@ -416,12 +416,11 @@ OPERATOR = [
|
|||
"airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeployOperator",
|
||||
),
|
||||
(
|
||||
"airflow.gcp.operators.speech_to_text.GcpSpeechToTextRecognizeSpeechOperator",
|
||||
"airflow.contrib.operators.gcp_speech_to_text_operator."
|
||||
"GcpSpeechToTextRecognizeSpeechOperator",
|
||||
"airflow.gcp.operators.speech_to_text.CloudSpeechToTextRecognizeSpeechOperator",
|
||||
"airflow.contrib.operators.gcp_speech_to_text_operator.GcpSpeechToTextRecognizeSpeechOperator",
|
||||
),
|
||||
(
|
||||
"airflow.gcp.operators.text_to_speech.GcpTextToSpeechSynthesizeOperator",
|
||||
"airflow.gcp.operators.text_to_speech.CloudTextToSpeechSynthesizeOperator",
|
||||
"airflow.contrib.operators.gcp_text_to_speech_operator.GcpTextToSpeechSynthesizeOperator",
|
||||
),
|
||||
(
|
||||
|
|
Загрузка…
Ссылка в новой задаче