ELSA SpeakELSA Speak

API使用例

Updated June 16, 2026·56 views

Automatically translated. View the original in English.

API使用例

スクリプトリクエスト

以下は、スクリプトAPIの使用例です。

Score_audioエンドポイント

このデモは、cURLコマンドを使用してLinux互換システムのコマンドラインで行います。

audio_pathパラメータを使用したcURLコマンド

この例では、「When the sunlight strikes raindrops in the air, they act like a prism and form a rainbow.」という文を使用し、この公開URL [https://elsa-api-docs.s3-eu-west-1.amazonaws.com/api\_samples/rainbow.wav]{{LINK0}} で利用可能な音声を使います。

curl -XPOST -s https://api.elsanow.io/api/v2/score_audio -F "api_plan=premium" -F "audio_path=https://elsa-api-docs.s3-eu-west-1.amazonaws.com/api_samples/rainbow.wav" -F sentence="When the sunlight strikes raindrops in the air, they act like a prism and form a rainbow" --header "Authorization: ELSA <API_token>"

audio_fileパラメータを使用したcURLコマンド

curl -XPOST -s https://api.elsanow.io/api/v2/score_audio -F "api_plan=premium" -F "audio_file=@<path_to_the_file>/rainbow.wav" -F sentence="When the sunlight strikes raindrops in the air, they act like a prism and form a rainbow" --header "Authorization: ELSA <API_token>"

「api_plan」パラメータを変更することで、より詳細またはより簡略化された結果を取得できます。

多肢選択サポートの例

上記と同じエンドポイントおよびパラメータを使用して、多肢選択問題のスコアリングも可能です。ELSAエンジンは、1) ユーザーの入力に最も適切に一致する単語/文を選択し、b) 単一文の場合と同様にその文をスコアリングします。多肢選択を実行するには、sentenceフィールドに候補文のリストを送信します。

sentence: ["sentence 0", "sentence 1"]

送信できる文の数に制限はありません。

curlコマンドでリストを送信する方法は次のとおりです。

sentence="[\"sentence 0\",\"sentence 1\"]"

アンスクリプトリクエスト

以下は、アンスクリプトAPIの使用例です。

Score_audio_plusエンドポイント

ELSA APIへの呼び出しを実装するには、Linux互換のコマンドラインで「curl」コマンドを使用できます。

audio_fileパラメータを使用したcURLコマンド

次のサンプルは、ローカル音声ファイルを使用して呼び出した際に、結果のjsonをダウンロードするリンクを返します(パスの前に「@」を忘れないでください)。

curl -XPOST -s https://api.elsanow.io/api/v1/score_audio_plus -F "api_plan=premium" -F "audio_file=@<path_to_your_file.wav>" --header "Authorization: ELSA <API_token>"

呼び出しへの応答としてjson自体を受け取りたい場合は、次のようにします。

 curl -XPOST -s https://api.elsanow.io/api/v1/score_audio_plus -F "api_plan=premium" -F "return_json=true" -F "audio_file=@<path_to_your_file.wav>" --header "Authorization: ELSA <API_token>"

ASRエンドポイント

ASRトランスクリプトおよび単語レベルの時間アライメントの使用例:

curl -XPOST -s https://api.elsanow.io/api/v1/asr -F "audio=@<path_to_your_file.wav>" --header "Authorization: ELSA <API_token>"
機能の非同期取得

非同期使用の例です。まず音声ファイルを指定してAPIを呼び出し、そこからstream_idを取得します。

curl -XPOST -s https://api.elsanow.io/api/v1/score_audio_plus -F "api_plan=premium" -F "audio_file=@<path_to_your_file.wav>" --header "Authorization: ELSA <API_token>" -F "sync=false" 

結果の例は次のとおりです。

{"stream_id":"<unique_stream_id>"}
結果エンドポイント

結果ファイル(ダウンロードリンクまたはjson構造として)を取得するには、結果エンドポイントを呼び出します。

1件の結果をダウンロードリンクとして取得する:
curl -XGET "https://api.elsanow.io/result?stream_id=<unique_stream_id>" --header "Authorization: ELSA <API_token>"

json形式で1件の結果を取得する

1件の結果を取得する:

curl -XGET "https://api.elsanow.io/result?stream_id=<unique_stream_id>&return_json=true" --header "Authorization: ELSA <API_token>"

複数の結果をまとめて取得する(このオプションでは、呼び出し時にjsonの返却は許可されていません)

curl -XGET "https://api.elsanow.io/result?stream_id=<unique_stream_id>&stream_id=<unique_stream_id>" --header "Authorization: ELSA <API_token>"
音声エンドポイント

音声ファイルを取得するには:

curl -XGET "https://api.elsanow.io/audio?stream_id=<unique_stream_id>" --header "Authorization: ELSA <API_token>"

Was this article helpful?

Or open the chat in the corner to ask follow-up questions.