Custom Speech モデルのデプロイ
この記事では、Custom Speech モデルのエンドポイントをデプロイする方法について説明します。 バッチ文字起こしを除き、Custom Speech モデルを使用するには、カスタム エンドポイントをデプロイする必要があります。
ヒント
バッチ文字起こし API で Custom Speech を使用するには、ホストされたデプロイ エンドポイントは必要ありません。 Custom Speech モデルがバッチ文字起こしにのみ使用される場合は、リソースを節約できます。 詳細については、「Speech Services の価格」を参照してください。
基本モデルまたはカスタム モデルのエンドポイントをデプロイし、後でエンドポイントを 更新 して、より適切なトレーニング済みモデルを使用できます。
注意
F0
Speech リソースによって使用されるエンドポイントは、7 日後に削除されます。
デプロイメント エンドポイントの追加
カスタム エンドポイントを作成するには、これらの手順に従います。
Speech Studio にサインインします。
[Custom Speech]> プロジェクト名 >[モデルのデプロイ] を選択します。
これが最初のエンドポイントの場合は、表にはエンドポイントが記載されていないことがわかります。 エンドポイントを作成したら、このページを使用して、デプロイされた各エンドポイントを追跡します。
[モデルのデプロイ] を選択して、新しいエンドポイント ウィザードを開始します。
[新しいエンドポイント] ページで、カスタム エンドポイントの名前と説明を入力します。
エンドポイントに関連付けるカスタム モデルを選択します。
必要に応じてチェック ボックスをオンにして、エンドポイントのトラフィックの音声ログと診断 ログ を有効にすることができます。
[追加] を選択して、エンドポイントを保存してデプロイします。
メインの [モデルのデプロイ] ページで、新しいエンドポイントの詳細 (名前、説明、状態、有効期限など) がテーブルに表示されます。 カスタム モデルを使用する新しいエンドポイントをインスタンス化するには、最大で 30 分かかることがあります。 デプロイの状態が [成功] に変わると、エンドポイントは使用できる状態です。
重要
モデルの有効期限の日付をメモします。 これは、音声認識にカスタム モデルを使用できる最後の日付です。 詳細については、「モデルとエンドポイントのライフサイクル」を参照してください。
エンドポイント リンクを選択すると、エンドポイント キー、エンドポイントの URL、サンプル コードなど、そのエンドポイントに固有の情報が表示されます。
エンドポイントを作成してモデルをデプロイするには、spx csr endpoint create
コマンドを使用します。 次の手順に従って要求パラメーターを作成します。
project
パラメーターを既存のプロジェクトの ID に設定します。 これは、Speech Studio でエンドポイントを表示および管理できるようにするためにも推奨されます。spx csr project list
コマンドを実行すると、使用できるプロジェクトを取得できます。- 必須の
model
パラメーターをエンドポイントにデプロイするモデルの ID に設定します。 - 必須の
language
パラメーターを設定します。 エンドポイント ロケールは、モデルのロケールと一致する必要があります。 ロケールを後から変更することはできません。 Speech CLIlanguage
パラメーターは、JSON 要求と応答のlocale
プロパティに対応します。 - 必須の
name
パラメーターを設定します。 これは、Speech Studio に表示される名前です。 Speech CLIname
パラメーターは、JSON 要求と応答のdisplayName
プロパティに対応します。 - 必要に応じて、
logging
パラメーターを設定できます。 エンドポイントのトラフィックの音声ログと診断 ログ を有効にするには、これをenabled
に設定します。 既定値は、false
です。
エンドポイントを作成してモデルをデプロイする Speech CLI コマンドの例を次に示します。
spx csr endpoint create --api-version v3.1 --project YourProjectId --model YourModelId --name "My Endpoint" --description "My Endpoint Description" --language "en-US"
次の形式で応答本文を受け取る必要があります。
{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/base/ae8d1643-53e4-4554-be4c-221dcfb471c5"
},
"links": {
"logs": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790/files/logs",
"restInteractive": "https://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restConversation": "https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restDictation": "https://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketInteractive": "wss://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketConversation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketDictation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790"
},
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/d40f2eb8-1abf-4f72-9008-a5ae8add82a4"
},
"properties": {
"loggingEnabled": true
},
"lastActionDateTime": "2022-05-19T15:27:51Z",
"status": "NotStarted",
"createdDateTime": "2022-05-19T15:27:51Z",
"locale": "en-US",
"displayName": "My Endpoint",
"description": "My Endpoint Description"
}
応答本文の最上位の self
プロパティはエンドポイントの URI です。 この URI を使用して、エンドポイントのプロジェクト、モデル、ログに関する詳細を取得します。 また、この URI を使用してエンドポイントを更新します。
エンドポイントに関する Speech CLI ヘルプを表示するには、次のコマンドを実行します。
spx help csr endpoint
エンドポイントを作成してモデルをデプロイするには、Speech to text REST API の Endpoints_Create 操作を使用します。 次の手順に従って要求本文を作成します。
project
プロパティを既存のプロジェクトの URI に設定します。 これは、Speech Studio でエンドポイントを表示および管理できるようにするためにも推奨されます。 Projects_List 要求を行うと、使用できるプロジェクトを取得できます。- 必須の
model
プロパティをエンドポイントにデプロイするモデルの ID に設定します。 - 必須の
locale
プロパティを設定します。 エンドポイント ロケールは、モデルのロケールと一致する必要があります。 ロケールを後から変更することはできません。 - 必須の
displayName
プロパティを設定します。 これは、Speech Studio に表示される名前です。 - 必要に応じて、
properties
のloggingEnabled
プロパティを設定できます。 エンドポイントのトラフィックの音声ログと診断 ログ を有効にするには、これをtrue
に設定します。 既定値は、false
です。
HTTP POST 要求は、以下の Endpoints_Create の例に示したように URI を使用して行います。 YourSubscriptionKey
は実際の Speech リソース キーに、YourServiceRegion
は実際の Speech リソース リージョンに置き換えたうえで、前述のように要求本文のプロパティを設定してください。
curl -v -X POST -H "Ocp-Apim-Subscription-Key: YourSubscriptionKey" -H "Content-Type: application/json" -d '{
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/d40f2eb8-1abf-4f72-9008-a5ae8add82a4"
},
"properties": {
"loggingEnabled": true
},
"displayName": "My Endpoint",
"description": "My Endpoint Description",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/base/ae8d1643-53e4-4554-be4c-221dcfb471c5"
},
"locale": "en-US",
}' "https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints"
次の形式で応答本文を受け取る必要があります。
{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/base/ae8d1643-53e4-4554-be4c-221dcfb471c5"
},
"links": {
"logs": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790/files/logs",
"restInteractive": "https://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restConversation": "https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restDictation": "https://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketInteractive": "wss://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketConversation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketDictation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790"
},
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/d40f2eb8-1abf-4f72-9008-a5ae8add82a4"
},
"properties": {
"loggingEnabled": true
},
"lastActionDateTime": "2022-05-19T15:27:51Z",
"status": "NotStarted",
"createdDateTime": "2022-05-19T15:27:51Z",
"locale": "en-US",
"displayName": "My Endpoint",
"description": "My Endpoint Description"
}
応答本文の最上位の self
プロパティはエンドポイントの URI です。 この URI を使用して、エンドポイントのプロジェクト、モデル、ログに関する詳細を取得します。 また、エンドポイントの更新または削除にもこの URI を使用します。
モデルの変更とエンドポイントの再デプロイ
エンドポイントは、同じ Speech リソースによって作成された別のモデルを使用するように更新できます。 前述のように、モデルの有効期限が切れる前に、エンドポイントのモデルを更新する必要があります。
新しいモデルを使用してカスタム エンドポイントを再デプロイするには:
- Speech Studio にサインインします。
- [Custom Speech]> プロジェクト名 >[モデルのデプロイ] を選択します。
- エンドポイントへのリンクを名前で選択し、[モデルの変更] を選択します。
- エンドポイントで使用する新しいモデルを選択します。
- [完了] を選択し、エンドポイントを保存して再デプロイします。
新しいモデルでカスタム エンドポイントを再デプロイするには、spx csr model update
コマンドを使用します。 次の手順に従って要求パラメーターを作成します。
- 必須の
endpoint
パラメーターをデプロイするエンドポイントの ID に設定します。 - 必須の
model
パラメーターをエンドポイントにデプロイするモデルの ID に設定します。
新しいモデルでカスタム エンドポイントを再デプロイする Speech CLI コマンドの例を次に示します。
spx csr endpoint update --api-version v3.1 --endpoint YourEndpointId --model YourModelId
次の形式で応答本文を受け取る必要があります。
{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/1e47c19d-12ca-4ba5-b177-9e04bd72cf98"
},
"links": {
"logs": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790/files/logs",
"restInteractive": "https://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restConversation": "https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restDictation": "https://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketInteractive": "wss://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketConversation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketDictation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790"
},
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/639d5280-8995-40cc-9329-051fd0fddd46"
},
"properties": {
"loggingEnabled": true
},
"lastActionDateTime": "2022-05-19T23:01:34Z",
"status": "NotStarted",
"createdDateTime": "2022-05-19T15:41:27Z",
"locale": "en-US",
"displayName": "My Endpoint",
"description": "My Updated Endpoint Description"
}
エンドポイントに関する Speech CLI ヘルプを表示するには、次のコマンドを実行します。
spx help csr endpoint
新しいモデルでカスタム エンドポイントをもう一度デプロイするには、Speech to text REST API の Endpoints_Update 操作を使用します。 次の手順に従って要求本文を作成します。
model
プロパティをエンドポイントにデプロイするモデルの ID に設定します。
HTTP PATCH 要求は、次の例に示すように URI を使って行います。 YourSubscriptionKey
を Speech リソースキーに置き換え、YourServiceRegion
を Speech リソース領域に置き換え、YourEndpointId
をエンドポイント ID に置き換え、前述のようにリクエスト本文のプロパティを設定します。
curl -v -X PATCH -H "Ocp-Apim-Subscription-Key: YourSubscriptionKey" -H "Content-Type: application/json" -d '{
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/1e47c19d-12ca-4ba5-b177-9e04bd72cf98"
}
}' "https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/YourEndpointId"
次の形式で応答本文を受け取る必要があります。
{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/1e47c19d-12ca-4ba5-b177-9e04bd72cf98"
},
"links": {
"logs": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790/files/logs",
"restInteractive": "https://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restConversation": "https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restDictation": "https://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketInteractive": "wss://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketConversation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketDictation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790"
},
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/639d5280-8995-40cc-9329-051fd0fddd46"
},
"properties": {
"loggingEnabled": true
},
"lastActionDateTime": "2022-05-19T23:01:34Z",
"status": "NotStarted",
"createdDateTime": "2022-05-19T15:41:27Z",
"locale": "en-US",
"displayName": "My Endpoint",
"description": "My Updated Endpoint Description"
}
再デプロイが完了するまで、数分間かかります。 それまでの間、エンドポイントはサービスを中断することなく、以前のモデルを使用します。
ログ データを表示する
ログ データは、エンドポイントの作成時に構成した場合にエクスポートできます。
エンドポイント ログをダウンロードするには:
- Speech Studio にサインインします。
- [Custom Speech]> プロジェクト名 >[モデルのデプロイ] を選択します。
- リンクをエンドポイント名で選択します。
- [コンテンツ ログ] で、[ログのダウンロード] を選択します。
エンドポイントのログを取得するには、spx csr endpoint list
コマンドを使用します。 次の手順に従って要求パラメーターを作成します。
- 必須の
endpoint
パラメーターをログを取得するエンドポイントの ID に設定します。
エンドポイントにログを取得する Speech CLI コマンドの例を次に示します。
spx csr endpoint list --api-version v3.1 --endpoint YourEndpointId
詳細を含む各ログ ファイルの場所は、応答本文で返されます。
エンドポイントのログを取得するには、まず Speech to text REST API の Endpoints_Get 操作を使用します。
HTTP GET 要求は、次の例に示すように URI を使用して行います。 YourEndpointId
をエンドポイント ID に置き換え、YourSubscriptionKey
を Speech リソース キーに置き換えて、YourServiceRegion
を Speech リソース リージョンに置き換えます。
curl -v -X GET "https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/YourEndpointId" -H "Ocp-Apim-Subscription-Key: YourSubscriptionKey"
次の形式で応答本文を受け取る必要があります。
{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790",
"model": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/1e47c19d-12ca-4ba5-b177-9e04bd72cf98"
},
"links": {
"logs": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/98375aaa-40c2-42c4-b65c-f76734fc7790/files/logs",
"restInteractive": "https://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restConversation": "https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"restDictation": "https://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketInteractive": "wss://eastus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketConversation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790",
"webSocketDictation": "wss://eastus.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?cid=98375aaa-40c2-42c4-b65c-f76734fc7790"
},
"project": {
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/projects/2f78cdb7-58ac-4bd9-9bc6-170e31483b26"
},
"properties": {
"loggingEnabled": true
},
"lastActionDateTime": "2022-05-19T23:41:05Z",
"status": "Succeeded",
"createdDateTime": "2022-05-19T23:41:05Z",
"locale": "en-US",
"displayName": "My Endpoint",
"description": "My Updated Endpoint Description"
}
前の応答本文の "logs" URI を使用して HTTP GET 要求を行います。 YourEndpointId
をエンドポイント ID に置き換え、YourSubscriptionKey
を Speech リソース キーに置き換えて、YourServiceRegion
を Speech リソース リージョンに置き換えます。
curl -v -X GET "https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/v3.1/endpoints/YourEndpointId/files/logs" -H "Ocp-Apim-Subscription-Key: YourSubscriptionKey"
詳細を含む各ログ ファイルの場所は、応答本文で返されます。
ログデータは、Microsoft が所有するストレージで 30 日間、使用できます。その後は削除されます。 所有するストレージ アカウントが Azure AI サービス サブスクリプションにリンクされている場合は、ログ データは自動的に削除されません。