bstraehle commited on
Commit
7d6d701
·
1 Parent(s): b049ea4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai, os
3
+
4
+ from dotenv import load_dotenv, find_dotenv
5
+ _ = load_dotenv(find_dotenv())
6
+
7
+ #openai.api_key = os.environ["OPENAI_API_KEY"]
8
+
9
+ def invoke(openai_api_key, youtube_url):
10
+ openai.api_key = openai_api_key
11
+ #
12
+ url="https://www.youtube.com/watch?v=jGwO_UgTS7I"
13
+ save_dir="C:/Users/bstra/Downloads"
14
+ loader = GenericLoader(
15
+ YoutubeAudioLoader([url], save_dir),
16
+ OpenAIWhisperParser()
17
+ )
18
+ docs = loader.load()
19
+ #
20
+ return completion
21
+
22
+ description = """<a href='https://www.gradio.app/'>Gradio</a> UI using <a href='https://platform.openai.com/'>OpenAI</a> API with Whisper 1 foundation model."""
23
+
24
+ gr.close_all()
25
+ demo = gr.Interface(fn=invoke,
26
+ inputs = [gr.Textbox(label = "OpenAI API Key", lines = 1), gr.Textbox(label = "YouTube URL", lines = 1)],
27
+ outputs = [gr.Textbox(label = "Automatic Speech Recognition", lines = 1)],
28
+ title = "Generative AI - Audio",
29
+ description = description)
30
+ demo.launch()