Spaces:
Runtime error
Runtime error
File size: 1,758 Bytes
b9e397f d4caf59 09780df 1bc78de ca0af61 09780df b28c9c0 d4caf59 ec44c32 09780df b9e397f ec44c32 b9e397f 89b131b 48959bc 09780df ec44c32 ca0af61 ec44c32 ca0af61 ec44c32 e228e84 ec44c32 b9e397f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import streamlit as st
from PIL import Image
from groq import Groq
import os
from transformers import pipeline
st.image('calamo.png', caption="", use_column_width=False)
import scipy.io.wavfile
synthesizer = pipeline("text-to-speech", "suno/bark")
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
# Other content of your app
st.title("plAIn Voice")
# Add more components here
# Define a function to process the input
def process_text(input_text):
prompt = '''
Eres un experto en lenguaje claro. Las pautas b谩sicas para lenguaje claro son:
- Expresar una idea por oraci贸n.
- Utilizar oraciones de treinta palabras o menos.
- Evitar la jerga.
- Seguir el orden sujeto, verbo y predicado.
- Utilizar una estructura l贸gica, organizando la informaci贸n de manera clara y coherente.
Eval煤a la calidad del lenguaje de este texto y sugiere las correcciones oportunas:"
'''
input = prompt + input_text
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": input,
}
],
model="mixtral-8x7b-32768",
)
return (chat_completion.choices[0].message.content)
def generate_audio(input_text):
tts = process_text(input_text)
speech = synthesizer(tts, forward_params={"do_sample": True})
scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
return "bark_out.wav"
user_input = st.text_input("Pega un texto para aclararlo y escuchar una lectura.")
if st.button('Aclarar'):
if user_input == "":
st.write("Pega un texto aqu铆")
else:
speech_file = generate_audio(user_input)
st.audio(speech_file, format='audio/wav')
|