edchengg
commited on
Commit
•
6aeab44
1
Parent(s):
7e868b7
audio
Browse files
app.py
CHANGED
@@ -8,7 +8,8 @@ def asr(url):
|
|
8 |
# download audio
|
9 |
# Options for youtube-dl
|
10 |
ydl_opts = {
|
11 |
-
|
|
|
12 |
}
|
13 |
|
14 |
|
@@ -17,8 +18,8 @@ def asr(url):
|
|
17 |
|
18 |
# Download the video
|
19 |
info_dict = ydl.extract_info(url, download=True)
|
20 |
-
|
21 |
-
audio_file= open(
|
22 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
23 |
output = openai.ChatCompletion.create(
|
24 |
model="gpt-3.5-turbo",
|
@@ -28,7 +29,7 @@ def asr(url):
|
|
28 |
)
|
29 |
|
30 |
# delete the video
|
31 |
-
os.system("rm {}".format(
|
32 |
return output['choices'][0]['message']['content'], transcript["text"]
|
33 |
|
34 |
title = """
|
|
|
8 |
# download audio
|
9 |
# Options for youtube-dl
|
10 |
ydl_opts = {
|
11 |
+
'format': 'bestaudio/best',
|
12 |
+
'outtmpl': 'audio_downloaded.%(ext)s',
|
13 |
}
|
14 |
|
15 |
|
|
|
18 |
|
19 |
# Download the video
|
20 |
info_dict = ydl.extract_info(url, download=True)
|
21 |
+
audio_file_name = "audio_downloaded.{}".format(info_dict["ext"])
|
22 |
+
audio_file= open(audio_file_name, "rb")
|
23 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
24 |
output = openai.ChatCompletion.create(
|
25 |
model="gpt-3.5-turbo",
|
|
|
29 |
)
|
30 |
|
31 |
# delete the video
|
32 |
+
os.system("rm {}".format(audio_file_name))
|
33 |
return output['choices'][0]['message']['content'], transcript["text"]
|
34 |
|
35 |
title = """
|