Auf dieser Seite wird beschrieben, wie Sie mithilfe der Clientbibliotheken vonGoogle Cloud eine Spracherkennungsanfrage in Ihrer bevorzugten Programmiersprache an Cloud Speech-to-Text senden.
Speech-to-Text ermöglicht die einfache Einbindung von Google-Spracherkennungstechnologien in Entwickleranwendungen. Sie können Audiodaten an die Speech-to-Text API senden, die dann eine Texttranskription dieser Audiodatei zurückgibt. Weitere Informationen zu diesem Dienst finden Sie unter Grundlagen von Cloud Speech-to-Text.
Hinweis
-
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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. 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.enablepermission. 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.
IAM aufrufen - Wählen Sie das Projekt aus.
- Klicken Sie auf Zugriffsrechte erteilen.
-
Geben Sie im Feld Neue Hauptkonten Ihre Nutzer-ID ein. Bei einem Nutzer in einem Mitarbeiteridentitätspool ist dies in der Regel dessen Kennung. Weitere Informationen erhalten Sie unter Mitarbeiteridentitätspool-Nutzer in IAM-Richtlinien darstellen oder von Ihrem Administrator.
- Wählen Sie in der Liste Rolle auswählen eine Rolle aus.
- Klicken Sie auf Weitere Rolle hinzufügen, wenn Sie weitere Rollen zuweisen möchten.
- Klicken Sie auf Speichern.
Install the Google Cloud CLI.
Konfigurieren Sie die gcloud CLI für die Verwendung Ihrer föderierten Identität.
Weitere Informationen finden Sie unter Mit Ihrer föderierten Identität in der gcloud CLI anmelden.
Führen Sie folgenden Befehl aus, um die gcloud CLI zu initialisieren:
gcloud initClientbibliotheken können Standardanmeldedaten für Anwendungen verwenden, um sich einfach bei Google APIs zu authentifizieren und Anfragen an diese APIs zu senden. Mit den Standardanmeldedaten für Anwendungen können Sie Ihre Anwendung lokal testen und bereitstellen, ohne den zugrunde liegenden Code zu ändern. Weitere Informationen finden Sie unter Für die Verwendung von Clientbibliotheken authentifizieren.
Create local authentication credentials for your user account:
gcloud auth application-default login
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.
Prüfen Sie außerdem, ob Sie die Clientbibliothek installiert haben.
Anfrage zur Audiotranskription stellen
Mit dem folgenden Code senden Sie eine
Recognize-Anfrage an die Speech-to-Text API.Java
Python
Sie haben Ihre erste Anfrage an Speech-to-Text gesendet.
Bereinigen
Mit den folgenden Schritten vermeiden Sie, dass Ihrem Google Cloud Konto die auf dieser Seite verwendeten Ressourcen in Rechnung gestellt werden:
-
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
Console
- 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.
gcloud
- 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.
Nächste Schritte
- Kurze Audiodateien transkribieren
- Weitere Informationen zum Transkribieren von Audiostreams
- Erfahren Sie mehr über das Transkribieren von langen Audiodateien.
- Lesen Sie die Best Practices-Dokumentation für maximale Leistung und Genauigkeit sowie für weitere Tipps.
-