このページでは、Speech-to-Text 暗号鍵を設定し Speech-to-Text リソースを暗号化する方法について説明します。
Speech-to-Text では、Cloud Key Management Serviceの暗号鍵を用意し、その鍵でデータを暗号化することができます。暗号化の詳細については、暗号化ページをご覧ください。
始める前に
- 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.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Speech-to-Text APIs.
-
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 に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
Install the Google Cloud CLI.
外部 ID プロバイダ(IdP)を使用している場合は、まずフェデレーション ID を使用して gcloud CLI にログインする必要があります。
gcloud CLI を初期化するには、次のコマンドを実行します。
gcloud init
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Speech-to-Text APIs.
-
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 に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
Install the Google Cloud CLI.
外部 ID プロバイダ(IdP)を使用している場合は、まずフェデレーション ID を使用して gcloud CLI にログインする必要があります。
gcloud CLI を初期化するには、次のコマンドを実行します。
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.
- Speech-to-Text で暗号鍵を指定する際に暗号化される内容について学習する。
- ストリーミング音声を文字に変換する方法を学習する。
- 長い音声ファイルを文字に変換する方法を学習する。
- 短い音声ファイルの文字変換を行う。
- 最高のパフォーマンスと精度を実現するための方法やヒントを確認する。ベスト プラクティスのドキュメントをご覧ください。
クライアント ライブラリは、アプリケーションのデフォルト認証情報を使用することによって、Google API で簡単に認証を行い、これらの API にリクエストを送信できます。アプリケーションのデフォルト認証情報を使用すると、ベースとなるコードを変更することなく、ローカルでアプリケーションのテストを行ったり、アプリケーションをデプロイしたりできます。詳細については、クライアント ライブラリを使用するための認証をご覧ください。
また、クライアント ライブラリがインストールされていることを確認してください。
Cloud Key Management Service 鍵へのアクセスを有効にする
Speech-to-Text はサービス アカウントを使用して Cloud KMS 鍵にアクセスします。デフォルトでは、サービス アカウントは Cloud KMS 鍵にアクセスできません。
サービス アカウントのメールアドレスは次のとおりです。
service-PROJECT_NUMBER@gcp-sa-speech.iam.gserviceaccount.com
Cloud KMS 鍵を使用して Speech-to-Text リソースを暗号化するには、このサービス アカウントに roles/cloudkms.cryptoKeyEncrypterDecrypter
ロールを付与します。
gcloud projects add-iam-policy-binding PROJECT_NUMBER \
--member=serviceAccount:service-PROJECT_NUMBER@gcp-sa-speech.iam.gserviceaccount.com \
--role=roles/cloudkms.cryptoKeyEncrypterDecrypter
プロジェクトの IAM ポリシーの詳細については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。
Cloud Storage へのアクセスの管理の詳細については、Cloud Storage ドキュメントのアクセス制御リストの作成と管理をご覧ください。
暗号鍵を指定する
次に、Config
リソースを使用して Speech-to-Text に暗号鍵を提供する例を示します。
Python
暗号鍵がプロジェクトの [Config
] リソースで指定されている場合、対応するロケーションで作成された新しいリソースは、この鍵を使用して暗号化されます。暗号化される内容と条件について詳しくは、暗号化ページをご覧ください。
暗号化されたリソースには、Speech-to-Text API レスポンスで kms_key_name
フィールドと kms_key_version_name
フィールドが入力されます。
暗号化を解除する
暗号鍵で今後のリソースが暗号化されないようにするには、上記のコードを使用して、リクエストの鍵として空の文字列(""
)を指定します。これにより、新しいリソースが暗号化されなくなります。このコマンドは、既存のリソースを復号しません。
鍵のローテーションと削除
鍵のローテーション時に、前のバージョンの Cloud KMS 鍵で暗号化されたリソースは、そのバージョンで暗号化されたままになります。鍵のローテーション後に作成されたリソースは、鍵の新しいデフォルト バージョンで暗号化されます。鍵のローテーション後に(Update*
メソッドを使用して)更新されたリソースは、鍵の新しいデフォルト バージョンで再度暗号化されます。
鍵が削除されると、Speech-to-Text はデータの復号やリソースの作成を行うことができません。また、削除された鍵で暗号化されたリソースにアクセスすることもできません。同様に、鍵の Speech-to-Text の権限を取り消すと、Speech-to-Text はデータの復号やリソースの作成を行うことができなくなります。また、Speech-to-Text の権限を取り消された鍵で暗号化されたリソースにアクセスできなくなります。
データを再暗号化する
リソースを再暗号化するには、Config
リソースの鍵仕様を更新した後に、リソースごとに対応する Update*
メソッドを呼び出します。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の操作を行います。
コンソール
gcloud