跳转到内容

transcriptions ​

import os
import openai
import requests
import time
import json
import time

API_SECRET_KEY = "你的Mishu获取的api_key";
BASE_URL = "https://mishu.one/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("test.wav");
    translation("test.wav");
    end = time.time()
    print('本次处理时间(s): ', end - start)

Mishu · API 开发文档