import os
import openai
import requests
import time
import json
import time
API_SECRET_KEY = "你的智增增获取的api_key";
BASE_URL = "https://api.zhizengzeng.com/v1"
# audio_transcriptions
def audio_transcriptions(file_name):
openai.api_key = API_SECRET_KEY
openai.api_base = BASE_URL
audio_file = open(file_name, "rb")
resp = openai.Audio.transcribe("whisper-1", audio_file)
json_str = json.dumps(resp, ensure_ascii=False) #打出中文来
print(json_str)
def translation(file_name):
openai.api_key = API_SECRET_KEY
openai.api_base = BASE_URL
audio_file = open(file_name, "rb")
resp = openai.Audio.translate("whisper-1", audio_file)
json_str = json.dumps(resp, ensure_ascii=False) #打出中文来
print(json_str)
if __name__ == '__main__':
start = time.time();
#audio_transcriptions("腾讯流量卡试音(1).wav");
translation("腾讯流量卡试音(1).wav");
end = time.time()
print('本次处理时间(s): ', end - start)