-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.py
24 lines (19 loc) · 885 Bytes
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import openai
import json
# openai.api_type = "azure"
# openai.api_base = "https://blessi-openai-europe.openai.azure.com/"
# openai.api_version = "2023-07-01-preview"
# openai.api_key = "bb7a3f910saddsasasd5adffadf883"
audio_file_path = "./audios/input.wav"
with open(audio_file_path, "rb") as audio_file:
response = openai.Audio.transcribe(engine="Blessi-whisper",model="whisper-1", file=audio_file)
print(response)
transcription_id = response['id']
# Poll the API until the transcription is complete
transcription_result = None
while transcription_result is None or transcription_result['status'] == 'processing':
response = openai.Audio.retrieve(transcription_id)
transcription_result = response['data']
print(f"Transcription status: {transcription_result['status']}")
transcript_text = transcription_result['text']
print(f"Transcription: {transcript_text}")