次の方法で共有


Speech CLI データストアを構成する

Speech CLI は、@ 記号を使用して参照できる構成ファイルの設定に依存することができます。 Speech CLI では、新しい設定は、Speech CLI 用に現在の作業ディレクトリ内に作成される新しい ./spx/data サブディレクトリに保存されます。 Speech CLI は、最初に現在の作業ディレクトリ、次にデータストア ./spx/data内の構成値を検索し、次にバイナリの最終的な読み取り専用データストアを含む他のデータストアで spx 検索します。

Speech CLI のクイックスタートでは、データストアを使用して自分と@region値を@key保存したので、各spxコマンドで指定する必要はありませんでした。 構成ファイルを使用して独自の構成設定を保存したり、これらを使用して実行時に生成された URL やその他の動的コンテンツを渡したりできることを覚えておいてください。

既定の構成ファイル (コマンドに固有の既定の設定の場合は @spx.default@default.config、および @*.default.config) の使用法など、データストア ファイルの詳細については、次のコマンドを入力してください。

spx help advanced setup

nodefaults

次の例では、@my.defaults 構成ファイルをクリアし、ファイル内の keyregion のキーと値のペアを追加し、spx recognize の呼び出しでこの構成を使用します。

spx config @my.defaults --clear
spx config @my.defaults --add key 000072626F6E20697320636F6F6C0000
spx config @my.defaults --add region westus

spx config @my.defaults

spx recognize --nodefaults @my.defaults --file hello.wav

動的構成

--output オプションを使って構成ファイルに動的コンテンツを書き込むこともできます。

たとえば、次のコマンドでは、カスタム音声モデルを作成し、新しいモデルの URL を構成ファイルに格納しています。 次のコマンドでは、その URL のモデルが使用できる状態になるまで待機してから制御を返します。

spx csr model create --name "Example 4" --datasets @my.datasets.txt --output url @my.model.txt
spx csr model status --model @my.model.txt --wait

次の例では、2 つの URL を @my.datasets.txt 構成ファイルに書き込みます。 このシナリオでは、--output にオプションの add キーワードを含めることによって、構成ファイルを作成したり、既存の構成ファイルに追加したりできます。

spx csr dataset create --name "LM" --kind Language --content https://crbn.us/data.txt --output url @my.datasets.txt
spx csr dataset create --name "AM" --kind Acoustic --content https://crbn.us/audio.zip --output add url @my.datasets.txt

spx config @my.datasets.txt

SPX config add

読みやすさ、柔軟性、利便性のために、出力オプションを選んだプリセット構成を使用できます。

たとえば、captioning に対して次のような要件があります。

  • 入力ファイル caption.this.mp4 から認識します。
  • WebVTT と SRT のキャプションをそれぞれファイル caption.vttcaption.srt に出力します。
  • 各認識イベントの offsetdurationresultidtext をファイル each.result.tsv に出力します。

次のように @caption.defaults というプリセット構成を作成することができます。

spx config @caption.defaults --clear
spx config @caption.defaults --add output.each.recognizing.result.offset=true
spx config @caption.defaults --add output.each.recognizing.result.duration=true
spx config @caption.defaults --add output.each.recognizing.result.resultid=true
spx config @caption.defaults --add output.each.recognizing.result.text=true
spx config @caption.defaults --add output.each.file.name=each.result.tsv
spx config @caption.defaults --add output.srt.file.name=caption.srt
spx config @caption.defaults --add output.vtt.file.name=caption.vtt

この設定は現在のディレクトリに caption.defaults というファイルで保存されます。 ファイルの内容は次のとおりです。

output.each.recognizing.result.offset=true
output.each.recognizing.result.duration=true
output.each.recognizing.result.resultid=true
output.each.recognizing.result.text=true
output.all.file.name=output.result.tsv
output.each.file.name=each.result.tsv
output.srt.file.name=caption.srt
output.vtt.file.name=caption.vtt

次に、キャプションを生成するために、次のコマンドを実行すると、@caption.defaults のプリセット構成から設定をインポートすることができます。

spx recognize --file caption.this.mp4 --format any --output vtt --output srt @caption.defaults

先ほどのプリセット構成を使うことは、次のコマンドを実行することと似ています。

spx recognize --file caption.this.mp4 --format any --output vtt file caption.vtt --output srt file caption.srt --output each file each.result.tsv --output all file output.result.tsv --output each recognizer recognizing result offset --output each recognizer recognizing duration --output each recognizer recognizing result resultid --output each recognizer recognizing text

次のステップ