Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,9 @@ import toml
|
|
3 |
from omegaconf import OmegaConf
|
4 |
from query import VectaraQuery
|
5 |
import os
|
6 |
-
from transformers import pipeline
|
|
|
|
|
7 |
|
8 |
import streamlit as st
|
9 |
from PIL import Image
|
@@ -105,17 +107,16 @@ def launch_bot():
|
|
105 |
# If assistant has most recently reaponded create audio of response
|
106 |
if st.session_state.messages[-1]["role"] == "assistant":
|
107 |
#text-to-speech
|
108 |
-
|
109 |
-
pipe = pipeline(model="suno/bark-small")
|
110 |
-
output = pipe()
|
111 |
|
112 |
-
|
113 |
-
|
|
|
114 |
# ST interface for audio
|
115 |
-
audio_file =
|
116 |
audio_bytes = audio_file.read()
|
117 |
|
118 |
-
st.audio(audio_bytes, format='audio/
|
119 |
|
120 |
sample_rate = 44100 # 44100 samples per second
|
121 |
seconds = 2 # Note duration of 2 seconds
|
|
|
3 |
from omegaconf import OmegaConf
|
4 |
from query import VectaraQuery
|
5 |
import os
|
6 |
+
from transformers import pipeline
|
7 |
+
import scipy
|
8 |
+
import numpy as np
|
9 |
|
10 |
import streamlit as st
|
11 |
from PIL import Image
|
|
|
107 |
# If assistant has most recently reaponded create audio of response
|
108 |
if st.session_state.messages[-1]["role"] == "assistant":
|
109 |
#text-to-speech
|
110 |
+
synthesiser = pipeline("text-to-speech", "suno/bark-small")
|
|
|
|
|
111 |
|
112 |
+
speech = synthesiser(response, forward_params={"do_sample": True})
|
113 |
+
|
114 |
+
scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
|
115 |
# ST interface for audio
|
116 |
+
audio_file = open('bark_out.wav', 'rb')
|
117 |
audio_bytes = audio_file.read()
|
118 |
|
119 |
+
st.audio(audio_bytes, format='audio/wav')
|
120 |
|
121 |
sample_rate = 44100 # 44100 samples per second
|
122 |
seconds = 2 # Note duration of 2 seconds
|