12345678910111213141516171819 |
- # For prerequisites running the following sample, visit https://help.aliyun.com/document_detail/611472.html
- import dashscope
- from urllib import request
- import json
- import api
- dashscope.api_key= api.api_key
- task_response=dashscope.audio.asr.Transcription.async_call(
- model='paraformer-v1',
- file_urls=['https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world.wav']
- )
- transcription_response=dashscope.audio.asr.Transcription.wait(task=task_response.output.task_id)
- transcription_url=transcription_response.output['results'][0]['transcription_url']
- transcription_results=json.loads(request.urlopen(transcription_url).read().decode('utf8'))
- print(json.dumps(transcription_results, indent=4, ensure_ascii=False))
|