-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathlisting1.py
More file actions
34 lines (24 loc) · 723 Bytes
/
Copy pathlisting1.py
File metadata and controls
34 lines (24 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
Created on Nov 10, 2023
@author: immanueltrummer
'''
import argparse
import openai
client = openai.OpenAI()
def transcribe(audio_path):
""" Transcribe audio file to text.
Args:
audio_path: path to audio file.
Returns:
transcribed text.
"""
with open(audio_path, 'rb') as audio_file:
transcription = client.audio.transcriptions.create(
file=audio_file, model='whisper-1')
return transcription.text
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('audiopath', type=str, help='Path to audio file')
args = parser.parse_args()
transcript = transcribe(args.audiopath)
print(transcript)