Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,14 +43,6 @@ def update(message):
|
|
43 |
except Exception as e:
|
44 |
return f"Error in response generation: {str(e)}"
|
45 |
|
46 |
-
|
47 |
-
#def text_to_speech(text):
|
48 |
-
#engine = pyttsx3.init()
|
49 |
-
#engine.say(text)
|
50 |
-
#engine.runAndWait()
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
# Function to transcribe audio data to text
|
55 |
def transcribe_audio(audio):
|
56 |
recognizer = sr.Recognizer()
|
@@ -60,27 +52,8 @@ def transcribe_audio(audio):
|
|
60 |
text = recognizer.recognize_google(audio_data, language="de-DE")
|
61 |
result = update(text)
|
62 |
#result=gr.Markdown(result)
|
63 |
-
|
64 |
-
engine = pyttsx3.init()
|
65 |
-
engine.say(result)
|
66 |
-
engine.runAndWait()
|
67 |
return result
|
68 |
-
|
69 |
-
query=text,
|
70 |
-
history=[],
|
71 |
-
system="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
|
72 |
-
api_name="/model_chat"
|
73 |
-
)
|
74 |
-
result = result[1]
|
75 |
-
result = result[0][1]
|
76 |
-
result=gr.Markdown(result)
|
77 |
-
#tts = gTTS(text=result, lang='de')
|
78 |
-
#tts.save("./chroma/output.mp3")
|
79 |
-
#os.system("start ./chroma/output.mp3") # Dies spielt die Audiodatei ab
|
80 |
-
#text_to_speech(result)
|
81 |
-
return result
|
82 |
-
#text = update(text)
|
83 |
-
#return text
|
84 |
except sr.UnknownValueError:
|
85 |
return "Speech recognition could not understand the audio."
|
86 |
except sr.RequestError as e:
|
@@ -172,12 +145,7 @@ def search_similar_documents(prompt):
|
|
172 |
#return "\n".join(formatted_results)
|
173 |
|
174 |
with gr.Blocks() as chat:
|
175 |
-
gr.Markdown("### Ask
|
176 |
-
#with gr.Row():
|
177 |
-
#prompt_input = gr.Textbox(label="Suche nach ähnlichen Dokumenten", placeholder="Gib einen Suchbegriff ein")
|
178 |
-
#search_output = gr.Textbox(label="Ähnliche Dokumente")
|
179 |
-
#with gr.Row():
|
180 |
-
#search_button = gr.Button("Suchen")
|
181 |
with gr.Row():
|
182 |
llm_output = gr.Textbox(label="LLM Answer")
|
183 |
with gr.Row():
|
@@ -188,7 +156,7 @@ with gr.Blocks() as chat:
|
|
188 |
llm_submit_button.click(ask_llm, inputs=llm_prompt_input, outputs=llm_output)
|
189 |
|
190 |
with gr.Blocks() as upload:
|
191 |
-
gr.Markdown("### upload", elem_classes="tab-header")
|
192 |
with gr.Row():
|
193 |
file_input = gr.File(label="Wähle eine PDF-Datei aus", type="filepath")
|
194 |
upload_output = gr.Textbox(label="Upload Status")
|
@@ -230,7 +198,7 @@ with gr.Blocks() as speech:
|
|
230 |
# Erstelle die Gradio-Schnittstelle
|
231 |
with gr.Blocks() as demo:
|
232 |
gr.TabbedInterface(
|
233 |
-
[chat, upload, suche
|
234 |
)
|
235 |
|
236 |
|
|
|
43 |
except Exception as e:
|
44 |
return f"Error in response generation: {str(e)}"
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Function to transcribe audio data to text
|
47 |
def transcribe_audio(audio):
|
48 |
recognizer = sr.Recognizer()
|
|
|
52 |
text = recognizer.recognize_google(audio_data, language="de-DE")
|
53 |
result = update(text)
|
54 |
#result=gr.Markdown(result)
|
|
|
|
|
|
|
|
|
55 |
return result
|
56 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
except sr.UnknownValueError:
|
58 |
return "Speech recognition could not understand the audio."
|
59 |
except sr.RequestError as e:
|
|
|
145 |
#return "\n".join(formatted_results)
|
146 |
|
147 |
with gr.Blocks() as chat:
|
148 |
+
gr.Markdown("### Ask the RKI Files", elem_classes="tab-header")
|
|
|
|
|
|
|
|
|
|
|
149 |
with gr.Row():
|
150 |
llm_output = gr.Textbox(label="LLM Answer")
|
151 |
with gr.Row():
|
|
|
156 |
llm_submit_button.click(ask_llm, inputs=llm_prompt_input, outputs=llm_output)
|
157 |
|
158 |
with gr.Blocks() as upload:
|
159 |
+
gr.Markdown("### File upload", elem_classes="tab-header")
|
160 |
with gr.Row():
|
161 |
file_input = gr.File(label="Wähle eine PDF-Datei aus", type="filepath")
|
162 |
upload_output = gr.Textbox(label="Upload Status")
|
|
|
198 |
# Erstelle die Gradio-Schnittstelle
|
199 |
with gr.Blocks() as demo:
|
200 |
gr.TabbedInterface(
|
201 |
+
[chat, upload, suche]
|
202 |
)
|
203 |
|
204 |
|