API 사용 예시
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 구조)을 가져오려면 결과 엔드포인트를 호출하세요.
결과 하나 검색, 다운로드 링크 받기:
curl -XGET "https://api.elsanow.io/result?stream_id=<unique_stream_id>" --header "Authorization: ELSA <API_token>"
json 형식으로 결과 하나 검색
결과 하나 검색:
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.