Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -8,26 +8,23 @@ from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLo
|
|
8 |
from dotenv import load_dotenv, find_dotenv
|
9 |
_ = load_dotenv(find_dotenv())
|
10 |
|
11 |
-
|
12 |
|
13 |
-
def invoke(
|
14 |
-
|
15 |
-
#
|
16 |
-
url = youtube_url
|
17 |
save_dir = "docs/youtube/"
|
18 |
loader = GenericLoader(
|
19 |
YoutubeAudioLoader([url], save_dir),
|
20 |
OpenAIWhisperParser()
|
21 |
)
|
22 |
docs = loader.load()
|
23 |
-
|
24 |
-
return completion
|
25 |
|
26 |
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."""
|
27 |
|
28 |
gr.close_all()
|
29 |
demo = gr.Interface(fn=invoke,
|
30 |
-
inputs = [gr.Textbox(label = "
|
31 |
outputs = [gr.Textbox(label = "Automatic Speech Recognition", lines = 1)],
|
32 |
title = "Generative AI - Audio",
|
33 |
description = description)
|
|
|
8 |
from dotenv import load_dotenv, find_dotenv
|
9 |
_ = load_dotenv(find_dotenv())
|
10 |
|
11 |
+
openai.api_key = os.environ["OPENAI_API_KEY"]
|
12 |
|
13 |
+
def invoke(url):
|
14 |
+
url = url
|
|
|
|
|
15 |
save_dir = "docs/youtube/"
|
16 |
loader = GenericLoader(
|
17 |
YoutubeAudioLoader([url], save_dir),
|
18 |
OpenAIWhisperParser()
|
19 |
)
|
20 |
docs = loader.load()
|
21 |
+
return docs[0].page_content
|
|
|
22 |
|
23 |
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."""
|
24 |
|
25 |
gr.close_all()
|
26 |
demo = gr.Interface(fn=invoke,
|
27 |
+
inputs = [gr.Textbox(label = "YouTube URL", lines = 1)],
|
28 |
outputs = [gr.Textbox(label = "Automatic Speech Recognition", lines = 1)],
|
29 |
title = "Generative AI - Audio",
|
30 |
description = description)
|