Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
import
|
| 7 |
# from langchain.agents import initialize_agent, Tool
|
| 8 |
# from langchain.agents.agent_types import AgentType
|
| 9 |
# from langchain.chat_models import ChatOpenAI
|
|
@@ -69,13 +69,16 @@ def transcribe_audio_tool(audio_path: str) -> str:
|
|
| 69 |
Returns:
|
| 70 |
str: Transcribed text or error message.
|
| 71 |
"""
|
|
|
|
| 72 |
try:
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
except Exception as e:
|
| 78 |
-
return f"Error transcribing audio: {
|
| 79 |
|
| 80 |
# --- Agent defining Class ---
|
| 81 |
class BasicAgent:
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
import openai
|
| 7 |
# from langchain.agents import initialize_agent, Tool
|
| 8 |
# from langchain.agents.agent_types import AgentType
|
| 9 |
# from langchain.chat_models import ChatOpenAI
|
|
|
|
| 69 |
Returns:
|
| 70 |
str: Transcribed text or error message.
|
| 71 |
"""
|
| 72 |
+
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
| 73 |
try:
|
| 74 |
+
with open(audio_path, "rb") as audio_file:
|
| 75 |
+
transcript = openai.audio.transcriptions.create(
|
| 76 |
+
model="whisper-1",
|
| 77 |
+
file=audio_file
|
| 78 |
+
)
|
| 79 |
+
return transcript#.text
|
| 80 |
except Exception as e:
|
| 81 |
+
return f"Error transcribing audio: {e}"
|
| 82 |
|
| 83 |
# --- Agent defining Class ---
|
| 84 |
class BasicAgent:
|