JackismyShephard
commited on
Commit
•
1d1e03e
1
Parent(s):
325312c
convert audio samples to int16
Browse files
app.py
CHANGED
@@ -31,6 +31,10 @@ speaker_embeddings = {
|
|
31 |
}
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
34 |
def predict(text, speaker, post_process):
|
35 |
if len(text.strip()) == 0:
|
36 |
return (16000, np.zeros(0))
|
@@ -49,9 +53,13 @@ def predict(text, speaker, post_process):
|
|
49 |
speech = pipe(text, forward_params=forward_params)
|
50 |
|
51 |
if post_process:
|
52 |
-
|
53 |
else:
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
|
56 |
|
57 |
def replace_danish_letters(text):
|
|
|
31 |
}
|
32 |
|
33 |
|
34 |
+
target_dtype = np.int16
|
35 |
+
max_range = np.iinfo(target_dtype).max
|
36 |
+
|
37 |
+
|
38 |
def predict(text, speaker, post_process):
|
39 |
if len(text.strip()) == 0:
|
40 |
return (16000, np.zeros(0))
|
|
|
53 |
speech = pipe(text, forward_params=forward_params)
|
54 |
|
55 |
if post_process:
|
56 |
+
sr, audio = enhance_audio(speech["audio"], speech["sampling_rate"], device)
|
57 |
else:
|
58 |
+
sr, audio = speech["sampling_rate"], speech["audio"]
|
59 |
+
|
60 |
+
audio = (audio * max_range).astype(np.int16)
|
61 |
+
|
62 |
+
return sr, audio
|
63 |
|
64 |
|
65 |
def replace_danish_letters(text):
|