גרסה 2 של Cloud Speech-to-Text API תומכת במשאב Google Cloud שנקרא recognizers. רכיבי זיהוי מייצגים הגדרות זיהוי מאוחסנות וניתנות לשימוש חוזר. אפשר להשתמש בהם כדי לקבץ באופן לוגי תמלילים או תנועה של האפליקציה.
לפני שמתחילים
- נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
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, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). 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.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
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 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, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). 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.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
אם אתם משתמשים במעטפת מקומית, צרו פרטי כניסה לאימות מקומי בחשבון המשתמש:
gcloud auth application-default login
אם אתם משתמשים ב-Cloud Shell, אתם לא צריכים לעשות את זה.
אם מוחזרת שגיאת אימות ואתם משתמשים בספק זהויות חיצוני (IdP), ודאו ש נכנסתם ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.
בספריות הלקוח אפשר להשתמש ב-Application Default Credentials כדי לעבור בקלות אימות מול Google APIs ולשלוח בקשות לאותם ממשקי API. באמצעות Application Default Credentials, אתם יכולים לבדוק את האפליקציה ברמה המקומית ולפרוס אותה בלי לשנות את הקוד שלה. מידע נוסף זמין במאמר אימות לצורך שימוש בספריות לקוח.
צריך גם לוודא שספריית הלקוח מותקנת.
הסבר על רכיבי זיהוי
מזהים הם הגדרות זיהוי שניתן להגדיר ולהשתמש בהן שוב. יצירת מזהים עם הגדרות זיהוי נפוצות עוזרת לפשט ולהקטין את הגודל של בקשות הזיהוי.
הרכיב העיקרי של מזהה הוא הגדרת ברירת המחדל שלו. זו ההגדרה של כל בקשת זיהוי שהכלי הזה מבצע. אפשר לשנות את ברירת המחדל הזו לכל בקשה. אתם יכולים להשאיר את הגדרות ברירת המחדל של התכונות שאתם צריכים בכל הבקשות למזהה מסוים, ולשנות תכונות ספציפיות בבקשות ספציפיות.
מומלץ להשתמש שוב במזהים כמה שיותר פעמים. יצירת חשבון שירות לכל בקשה מגדילה באופן משמעותי את זמן האחזור של האפליקציה וצורכת את מכסות המשאבים. יוצרים אותם לעיתים רחוקות במהלך השילוב וההגדרה, ואז משתמשים בהם שוב לבקשות זיהוי.
יצירת מזהים
דוגמה ליצירת מזהה שאפשר להשתמש בו כדי לשלוח בקשות זיהוי:
Python
שימוש במזהה דיבור קיים לשליחת בקשות
דוגמה לשליחת כמה בקשות זיהוי באמצעות אותו מזהה:
Python
הפעלת תכונות במנגנון זיהוי
אפשר להשתמש במזהים כדי להפעיל תכונות שונות בזיהוי, כמו פיסוק אוטומטי או סינון שפה גסה.
הנה דוגמה להפעלת פיסוק אוטומטי במנגנון זיהוי, שמאפשר פיסוק אוטומטי בבקשת הזיהוי באמצעות מנגנון הזיהוי הזה:
Python
שינוי תכונות של מזהה בבקשות זיהוי
בדוגמה הבאה מופעלות כמה תכונות במזהה, אבל מושבת הפיסוק האוטומטי לבקשת הזיהוי הזו:
Python
שליחת בקשות ללא רכיבי זיהוי
השימוש במזהים הוא אופציונלי בבקשות זיהוי. כדי לשלוח בקשה בלי רכיב לזיהוי דיבור, משתמשים במזהה משאב של רכיב לזיהוי דיבור _ במיקום שבו שולחים את הבקשה. לדוגמה:
Python
הסרת המשאבים
כדי לא לצבור חיובים לחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, פועלים לפי השלבים הבאים.
-
אם תרצו, תוכלו לבטל את פרטי הכניסה שיצרתם ולמחוק את הקובץ המקומי של פרטי הכניסה.
gcloud auth application-default revoke
-
אם רוצים, מבטלים את פרטי הכניסה של ה-CLI של gcloud.
gcloud auth revoke
המסוף
gcloud
כדי למחוק Google Cloud פרויקט:
gcloud projects delete PROJECT_ID
המאמרים הבאים
- איך מתמללים קובצי אודיו קצרים
- איך מתמללים אודיו בסטרימינג
- איך מתמללים קובצי אודיו ארוכים
- כדי לקבל את הביצועים והדיוק הטובים ביותר, וטיפים נוספים, עיינו במסמכי התיעוד בנושא שיטות מומלצות.