Spaces:
Sleeping
Sleeping
Manu
commited on
Commit
·
0e826bb
1
Parent(s):
e8b9495
revert to wav file recording
Browse files
app.py
CHANGED
@@ -41,6 +41,11 @@ def synthesise_audio(text, forward_params=None):
|
|
41 |
raise ValueError("Error: El texto es demasiado largo. Por favor, limita tu entrada a 100 caracteres.")
|
42 |
|
43 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
|
|
|
|
|
|
|
|
|
|
44 |
# sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
|
45 |
# return "speech.wav"
|
46 |
|
@@ -59,21 +64,33 @@ def synthesise_audio(text, forward_params=None):
|
|
59 |
#return speech["audio"]
|
60 |
|
61 |
#return audio
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
|
64 |
# Create an in-memory buffer to store the audio data
|
65 |
-
|
|
|
66 |
|
67 |
# Write the audio data to the in-memory buffer
|
68 |
-
|
|
|
69 |
|
70 |
# Move the buffer cursor to the beginning of the buffer
|
71 |
-
audio_buffer.seek(0)
|
72 |
|
73 |
# Read the audio data from the in-memory buffer into a numpy array
|
74 |
-
audio
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
return audio, sr
|
77 |
|
78 |
|
79 |
|
@@ -85,8 +102,8 @@ input_text = gr.Textbox(lines=10, label="Enter text here")
|
|
85 |
|
86 |
demo = gr.Interface(fn=synthesise_audio,
|
87 |
inputs=input_text,
|
88 |
-
|
89 |
-
outputs = gr.Audio(type="numpy"),
|
90 |
description="----- manuai Text To Speech generator -----",
|
91 |
allow_flagging = False)
|
92 |
|
|
|
41 |
raise ValueError("Error: El texto es demasiado largo. Por favor, limita tu entrada a 100 caracteres.")
|
42 |
|
43 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
44 |
+
|
45 |
+
|
46 |
+
sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
|
47 |
+
return "speech.wav"
|
48 |
+
|
49 |
# sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
|
50 |
# return "speech.wav"
|
51 |
|
|
|
64 |
#return speech["audio"]
|
65 |
|
66 |
#return audio
|
67 |
+
|
68 |
+
# Ensure audio is a numpy array
|
69 |
+
#if isinstance(speech["audio"], int):
|
70 |
+
# audio = np.array([speech["audio"]])
|
71 |
+
#else:
|
72 |
+
# audio = speech["audio"]
|
73 |
|
74 |
|
75 |
# Create an in-memory buffer to store the audio data
|
76 |
+
#print("Creating in-memory buffer")
|
77 |
+
#audio_buffer = io.BytesIO()
|
78 |
|
79 |
# Write the audio data to the in-memory buffer
|
80 |
+
#print("Writing audio data to in-memory buffer")
|
81 |
+
#sf.write(audio_buffer, speech["audio"], samplerate=speech["sampling_rate"], format="WAV")
|
82 |
|
83 |
# Move the buffer cursor to the beginning of the buffer
|
84 |
+
#audio_buffer.seek(0)
|
85 |
|
86 |
# Read the audio data from the in-memory buffer into a numpy array
|
87 |
+
#print("Reading audio data from in-memory buffer")
|
88 |
+
#audio, sr = sf.read(audio_buffer)
|
89 |
+
#print("Audio data read from in-memory buffer, returning audio data and sample rate")
|
90 |
+
# Ensure audio is a numpy array before returning
|
91 |
+
#audio = np.array(audio)
|
92 |
|
93 |
+
#return audio, sr
|
94 |
|
95 |
|
96 |
|
|
|
102 |
|
103 |
demo = gr.Interface(fn=synthesise_audio,
|
104 |
inputs=input_text,
|
105 |
+
outputs="audio",
|
106 |
+
#outputs = gr.Audio(type="numpy"),
|
107 |
description="----- manuai Text To Speech generator -----",
|
108 |
allow_flagging = False)
|
109 |
|