Esta sección muestra cómo transcribir audio de transmisión, como la entrada de un micrófono a texto.
El reconocimiento de voz de transmisión te permite transmitir audio a Speech-to-Text y recibir resultados de reconocimiento de voz de transmisión en tiempo real a medida que se procesa el audio. También puedes consultar los límites de audio para solicitudes de reconocimiento de voz de transmisión. El reconocimiento de voz de transmisión solo está disponible a través de gRPC.
Antes de comenzar
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Speech-to-Text APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Make sure that you have the following role or roles on the project: Cloud Speech Administrator
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Ir a IAM - Selecciona el proyecto.
- Haz clic en Otorgar acceso.
-
En el campo Principales nuevas, ingresa tu identificador de usuario. Esta suele ser la dirección de correo electrónico de una Cuenta de Google.
- En la lista Seleccionar un rol, elige uno.
- Para otorgar roles adicionales, haz clic en Agregar otro rol y agrega uno más.
- Haz clic en Guardar.
Install the Google Cloud CLI.
Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.
Para inicializar gcloud CLI, ejecuta el siguiente comando:
gcloud init
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Speech-to-Text APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Make sure that you have the following role or roles on the project: Cloud Speech Administrator
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Ir a IAM - Selecciona el proyecto.
- Haz clic en Otorgar acceso.
-
En el campo Principales nuevas, ingresa tu identificador de usuario. Esta suele ser la dirección de correo electrónico de una Cuenta de Google.
- En la lista Seleccionar un rol, elige uno.
- Para otorgar roles adicionales, haz clic en Agregar otro rol y agrega uno más.
- Haz clic en Guardar.
Install the Google Cloud CLI.
Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.
Para inicializar gcloud CLI, ejecuta el siguiente comando:
gcloud init
-
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Optional: Revoke the authentication credentials that you created, and delete the local credential file.
gcloud auth application-default revoke
-
Optional: Revoke credentials from the gcloud CLI.
gcloud auth revoke
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
- Consulta la documentación de referencia para el reconocimiento de transmisión.
- Practica transcribir archivos de audio cortos.
- Obtén información sobre cómo transcribir archivos de audio largos.
- Transcribe archivos de audio con Chirp.
- Para mejorar el rendimiento y la exactitud, así como ver otras sugerencias, consulta la documentación de prácticas recomendadas.
Las bibliotecas cliente pueden usar las credenciales predeterminadas de la aplicación para autenticarse fácilmente con las APIs de Google y enviar solicitudes a esas API. Con las credenciales predeterminadas de la aplicación, puedes probar tu aplicación de forma local y, luego, implementarla sin cambiar el código subyacente. Si deseas obtener más información, consulta Autentícate para usar las bibliotecas cliente.
También asegúrate de haber instalado la biblioteca cliente.
Realiza reconocimiento de voz de transmisión en un archivo local
El siguiente es un ejemplo de cómo realizar el reconocimiento de voz de transmisión en un archivo de audio local. Existe un límite de 25 KB para el audio enviado en las solicitudes de una transmisión. Este límite se aplica a la solicitud StreamingRecognize
inicial y al tamaño de cada mensaje individual en la transmisión. Si se supera este límite, se arroja un error.
Python
Si bien puedes transmitir un archivo de audio local a la API de Speech-to-Text, se recomienda que realices un reconocimiento de audio síncrono.
Limpia
Para evitar que se apliquen cargos a tu cuenta de Google Cloud por los recursos que usaste en esta página, sigue estos pasos.
Console
gcloud