Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,28 @@ custom_css = """
|
|
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()
|
@@ -31,7 +53,7 @@ def transcribe_audio(audio):
|
|
31 |
audio_data = recognizer.record(source)
|
32 |
try:
|
33 |
text = recognizer.recognize_google(audio_data, language="de-DE")
|
34 |
-
text =
|
35 |
return text
|
36 |
except sr.UnknownValueError:
|
37 |
return "Speech recognition could not understand the audio."
|
|
|
24 |
# Verwende die integrierten Embeddings von ChromaDB
|
25 |
embedding_function = embedding_functions.DefaultEmbeddingFunction()
|
26 |
|
27 |
+
def update(message):
|
28 |
+
url = "https://api.groq.com/openai/v1/chat/completions"
|
29 |
+
headers = {
|
30 |
+
"Authorization": groq,
|
31 |
+
"Content-Type": "application/json"
|
32 |
+
}
|
33 |
+
data = {
|
34 |
+
"messages": [
|
35 |
+
{
|
36 |
+
"role": "user",
|
37 |
+
"content": message
|
38 |
+
}
|
39 |
+
],
|
40 |
+
"model": "mixtral-8x7b-32768",
|
41 |
+
"temperature": 0.2
|
42 |
+
}
|
43 |
+
|
44 |
+
response = requests.post(url, headers=headers, data=json.dumps(data))
|
45 |
+
return response.json()['choices'][0]['message']['content']
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
# Function to transcribe audio data to text
|
50 |
def transcribe_audio(audio):
|
51 |
recognizer = sr.Recognizer()
|
|
|
53 |
audio_data = recognizer.record(source)
|
54 |
try:
|
55 |
text = recognizer.recognize_google(audio_data, language="de-DE")
|
56 |
+
text = update(text)
|
57 |
return text
|
58 |
except sr.UnknownValueError:
|
59 |
return "Speech recognition could not understand the audio."
|