rdlf commited on
Commit
ec44c32
·
verified ·
1 Parent(s): 963730f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -3,9 +3,16 @@ from PIL import Image
3
  from groq import Groq
4
  import os
5
 
6
- st.image('endesa.jpeg', caption="", use_column_width=False)
7
  st.image('calamo.png', caption="", use_column_width=False)
8
 
 
 
 
 
 
 
 
 
9
  client = Groq(
10
  api_key=os.environ.get("GROQ_API_KEY"),
11
  )
@@ -13,10 +20,8 @@ client = Groq(
13
  st.write("# Inicio")
14
 
15
  # Other content of your app
16
- st.title("plAIn")
17
  # Add more components here
18
- # Create a text input widget
19
- user_input = st.text_input('Pega tu texto:', '')
20
 
21
  # Define a function to process the input
22
  def process_text(input_text):
@@ -41,9 +46,25 @@ def process_text(input_text):
41
  model="mixtral-8x7b-32768",
42
  )
43
  return (chat_completion.choices[0].message.content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- # Call the function with the user input
46
  processed_output = process_text(user_input)
47
 
48
  # Display the processed output
49
- st.write('Texto procesado:', processed_output)
 
3
  from groq import Groq
4
  import os
5
 
 
6
  st.image('calamo.png', caption="", use_column_width=False)
7
 
8
+ # Use a pipeline as a high-level helper
9
+ from transformers import pipeline
10
+ import scipy.io.wavfile
11
+
12
+ synthesizer = pipeline("text-to-speech", "suno/bark")
13
+
14
+
15
+
16
  client = Groq(
17
  api_key=os.environ.get("GROQ_API_KEY"),
18
  )
 
20
  st.write("# Inicio")
21
 
22
  # Other content of your app
23
+ st.title("plAIn Voice")
24
  # Add more components here
 
 
25
 
26
  # Define a function to process the input
27
  def process_text(input_text):
 
46
  model="mixtral-8x7b-32768",
47
  )
48
  return (chat_completion.choices[0].message.content)
49
+ def generate_audio(input_text):
50
+ tts = process_text(input_text)
51
+ speech = synthesizer(tts, forward_params={"do_sample": True})
52
+ scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
53
+ return "bark_out.wav"
54
+
55
+ user_input = st.text_input("Pega un texto para aclararlo y escuchar una lectura.")
56
+
57
+ if st.button('Convert'):
58
+ if user_input == "":
59
+ st.write("Please enter some text")
60
+ else:
61
+ speech_file = text_to_speech(user_input)
62
+ st.audio(speech_file, format='audio/wav')
63
+
64
+
65
 
66
+ '''# Call the function with the user input
67
  processed_output = process_text(user_input)
68
 
69
  # Display the processed output
70
+ st.write('Texto procesado:', processed_output)'''