Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from gradio_client import Client
|
|
6 |
from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT
|
7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
8 |
import os
|
|
|
9 |
os.system("pip install --upgrade gradio")
|
10 |
|
11 |
# Initialisiere ChromaDB
|
@@ -23,6 +24,22 @@ custom_css = """
|
|
23 |
# Verwende die integrierten Embeddings von ChromaDB
|
24 |
embedding_function = embedding_functions.DefaultEmbeddingFunction()
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
27 |
def ask_llm(llm_prompt_input):
|
28 |
# Erstelle Embedding für den Prompt
|
@@ -139,7 +156,16 @@ with gr.Blocks() as suche:
|
|
139 |
with gr.Row():
|
140 |
search_button = gr.Button("Suchen")
|
141 |
search_button.click(search_similar_documents, inputs=prompt_input, outputs=search_output)
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
# Erstelle die Gradio-Schnittstelle
|
145 |
with gr.Blocks() as demo:
|
|
|
6 |
from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT
|
7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
8 |
import os
|
9 |
+
import speech_recognition as sr
|
10 |
os.system("pip install --upgrade gradio")
|
11 |
|
12 |
# Initialisiere ChromaDB
|
|
|
24 |
# Verwende die integrierten Embeddings von ChromaDB
|
25 |
embedding_function = embedding_functions.DefaultEmbeddingFunction()
|
26 |
|
27 |
+
# Function to transcribe audio data to text
|
28 |
+
def transcribe_audio(audio):
|
29 |
+
recognizer = sr.Recognizer()
|
30 |
+
with sr.AudioFile(audio) as source:
|
31 |
+
audio_data = recognizer.record(source)
|
32 |
+
try:
|
33 |
+
text = recognizer.recognize_google(audio_data)
|
34 |
+
return text
|
35 |
+
except sr.UnknownValueError:
|
36 |
+
return "Speech recognition could not understand the audio."
|
37 |
+
except sr.RequestError as e:
|
38 |
+
return f"Could not request results from Google Speech Recognition service; {e}"
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
44 |
def ask_llm(llm_prompt_input):
|
45 |
# Erstelle Embedding für den Prompt
|
|
|
156 |
with gr.Row():
|
157 |
search_button = gr.Button("Suchen")
|
158 |
search_button.click(search_similar_documents, inputs=prompt_input, outputs=search_output)
|
159 |
+
|
160 |
+
|
161 |
+
with gr.Blocks() as speech:
|
162 |
+
gr.Markdown("### audio", elem_classes="tab-header")
|
163 |
+
with gr.Row():
|
164 |
+
sr_inputs=gr.Audio(source="microphone", type="filepath"),
|
165 |
+
sr_outputs=gr.Textbox(label="Transcribed Text")
|
166 |
+
with gr.Row():
|
167 |
+
submit_button = gr.Button("rec")
|
168 |
+
submit_button.click(transcribe_audio, inputs=sr_inputs, outputs=sr_outputs)
|
169 |
|
170 |
# Erstelle die Gradio-Schnittstelle
|
171 |
with gr.Blocks() as demo:
|