From 5842ff635063619a162c50d4cb1e3054dfaad822 Mon Sep 17 00:00:00 2001 From: Yiyang Li Date: Mon, 16 Dec 2024 10:45:34 +0800 Subject: [PATCH] 2 clients updates --- paraformer-client.py | 34 ++++++++++++++++++++++++++++++++ whisper-v3-turbo-clint.py | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 paraformer-client.py create mode 100644 whisper-v3-turbo-clint.py diff --git a/paraformer-client.py b/paraformer-client.py new file mode 100644 index 0000000..8e78e07 --- /dev/null +++ b/paraformer-client.py @@ -0,0 +1,34 @@ +import requests +import json +import time + +start_time = time.time() +# Flask API的URL +api_url = 'http://122.51.206.54:4800/asr' + +# 要识别的音频文件的URL +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/Chinese.wav' +audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/English.wav' +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/Cantonese.wav' +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-8akzhpov.wav' + +# 构造请求数据 +data = { + 'audio_url': audio_url +} + +# 发送POST请求 +headers = {'Content-Type': 'application/json'} +response = requests.post(api_url, data=json.dumps(data), headers=headers) + +# 处理响应 +if response.status_code == 200: + result = response.json() + # 假设返回的结果中包含一个'predictions'键,其值是一个包含识别结果的列表 + for prediction in result['predictions']: + print('Recognized Text:', prediction['text']) +else: + print('Error:', response.json()) +end_time = time.time() +elapsed_time = end_time - start_time +print(f"代码块运行时长: {elapsed_time:.6f} 秒") \ No newline at end of file diff --git a/whisper-v3-turbo-clint.py b/whisper-v3-turbo-clint.py new file mode 100644 index 0000000..a02727f --- /dev/null +++ b/whisper-v3-turbo-clint.py @@ -0,0 +1,41 @@ +import requests +import json +import time + +start_time = time.time() +# flask_url = 'http://127.0.0.1:5000/transcribe' +# sensevoice调用地址 +# flask_url = 'http://122.51.206.54:4578/transcribe' +# flask_url = 'http://122.51.206.54:5000/transcribe' +# whisperv3调用地址 +flask_url = 'http://122.51.206.54:4900/whisper' +# 文件地址 +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/Chinese.wav' +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-fllxt32b.wav' # 中文 +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-vahlmelz.wav' # 中文2 +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-dtvoq4va.wav' # 英文 +audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-jy2hk0qf.wav' # 粤语 +# audio_url = 'https://cm-1255337128.cos.ap-guangzhou.myqcloud.com/asr-service/20241213-8akzhpov.wav' # 日文 + +# audio_url = "D:/Work/whisper/Chinese.wav" +# audio_url = "D:/Work/whisper/English.wav" +# audio_url = "D:/Work/whisper/Cantonese.wav'" +# audio_url = "D:/Work/whisper/Japanese.wav" + +# 发送 POST 请求 +response = requests.post( + flask_url, + json={'audio_url': audio_url} +) + +# 处理响应 +if response.status_code == 200: + result = response.json() + print("Transcribed Text:", result['text']) + +else: + print("Error:", response.json()) +end_time = time.time() +elapsed_time = end_time - start_time +print(f"代码块运行时长: {elapsed_time:.6f} 秒") +