Improving readability of app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,13 @@ import streamlit as st
|
|
2 |
from audio_recorder_streamlit import audio_recorder
|
3 |
from groq import Groq
|
4 |
import os
|
5 |
-
from dotenv import load_dotenv
|
6 |
from langchain_groq import ChatGroq
|
7 |
from langchain_core.output_parsers import StrOutputParser
|
8 |
from langchain_core.prompts import ChatPromptTemplate
|
9 |
import edge_tts
|
10 |
import asyncio
|
11 |
-
|
12 |
load_dotenv()
|
13 |
-
client = Groq(api_key=os.getenv('GROQ_API_KEY'))
|
14 |
-
model = 'whisper-large-v3'
|
15 |
|
16 |
#Front end using streamlit
|
17 |
def frontend():
|
@@ -48,6 +45,7 @@ def data_to_file(recorded_audio):
|
|
48 |
|
49 |
#Function for audio to text
|
50 |
def audio_to_text(audio_path):
|
|
|
51 |
with open(audio_path, 'rb') as file:
|
52 |
transcription = client.audio.translations.create(
|
53 |
file=(audio_path, file.read()),
|
@@ -76,7 +74,8 @@ def answer(user_question):
|
|
76 |
# Audio conversion
|
77 |
async def convert_audio(text):
|
78 |
filename = "output.mp3"
|
79 |
-
|
|
|
80 |
await communicte.save(filename)
|
81 |
|
82 |
frontend()
|
|
|
2 |
from audio_recorder_streamlit import audio_recorder
|
3 |
from groq import Groq
|
4 |
import os
|
|
|
5 |
from langchain_groq import ChatGroq
|
6 |
from langchain_core.output_parsers import StrOutputParser
|
7 |
from langchain_core.prompts import ChatPromptTemplate
|
8 |
import edge_tts
|
9 |
import asyncio
|
10 |
+
from dotenv import load_dotenv
|
11 |
load_dotenv()
|
|
|
|
|
12 |
|
13 |
#Front end using streamlit
|
14 |
def frontend():
|
|
|
45 |
|
46 |
#Function for audio to text
|
47 |
def audio_to_text(audio_path):
|
48 |
+
client = Groq(api_key=os.getenv('GROQ_API_KEY'))
|
49 |
with open(audio_path, 'rb') as file:
|
50 |
transcription = client.audio.translations.create(
|
51 |
file=(audio_path, file.read()),
|
|
|
74 |
# Audio conversion
|
75 |
async def convert_audio(text):
|
76 |
filename = "output.mp3"
|
77 |
+
voice = "fr-FR-VivienneMultilingualNeural"
|
78 |
+
communicte = edge_tts.Communicate(text, voice)
|
79 |
await communicte.save(filename)
|
80 |
|
81 |
frontend()
|