|
@@ -2,6 +2,8 @@ import os
|
|
|
import subprocess
|
|
|
|
|
|
from kalliope.core.TTS.TTSModule import TTSModule
|
|
|
+import sox
|
|
|
+
|
|
|
import logging
|
|
|
import sys
|
|
|
|
|
@@ -13,6 +15,7 @@ class Pico2wave(TTSModule):
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
super(Pico2wave, self).__init__(**kwargs)
|
|
|
+ self.samplerate = kwargs.get('samplerate', None)
|
|
|
|
|
|
def say(self, words):
|
|
|
"""
|
|
@@ -44,6 +47,13 @@ class Pico2wave(TTSModule):
|
|
|
|
|
|
# generate the file with pico2wav
|
|
|
subprocess.call(final_command, stderr=sys.stderr)
|
|
|
-
|
|
|
+
|
|
|
+ # convert samplerate
|
|
|
+ if self.samplerate is not None:
|
|
|
+ tfm = sox.Transformer()
|
|
|
+ tfm.rate(samplerate=self.samplerate)
|
|
|
+ tfm.build(str(tmp_path), str(tmp_path)+("tmp_name.wav"))
|
|
|
+ os.rename(str(tmp_path)+("tmp_name.wav"), tmp_path)
|
|
|
+
|
|
|
# remove the extension .wav
|
|
|
os.rename(tmp_path, self.file_path)
|