|
|
@ -147,7 +147,7 @@ class SpeedPerturbationSox():
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import soxbindings as sox
|
|
|
|
import soxbindings as sox
|
|
|
|
except:
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from paddlespeech.s2t.utils import dynamic_pip_install
|
|
|
|
from paddlespeech.s2t.utils import dynamic_pip_install
|
|
|
|
package = "sox"
|
|
|
|
package = "sox"
|
|
|
@ -155,8 +155,10 @@ class SpeedPerturbationSox():
|
|
|
|
package = "soxbindings"
|
|
|
|
package = "soxbindings"
|
|
|
|
dynamic_pip_install.install(package)
|
|
|
|
dynamic_pip_install.install(package)
|
|
|
|
import soxbindings as sox
|
|
|
|
import soxbindings as sox
|
|
|
|
except:
|
|
|
|
except Exception:
|
|
|
|
raise RuntimeError("Can not install soxbindings on your system." )
|
|
|
|
raise RuntimeError(
|
|
|
|
|
|
|
|
"Can not install soxbindings on your system.")
|
|
|
|
|
|
|
|
self.sox = sox
|
|
|
|
|
|
|
|
|
|
|
|
if utt2ratio is not None:
|
|
|
|
if utt2ratio is not None:
|
|
|
|
self.utt2ratio = {}
|
|
|
|
self.utt2ratio = {}
|
|
|
@ -200,7 +202,7 @@ class SpeedPerturbationSox():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ratio = self.state.uniform(self.lower, self.upper)
|
|
|
|
ratio = self.state.uniform(self.lower, self.upper)
|
|
|
|
|
|
|
|
|
|
|
|
tfm = sox.Transformer()
|
|
|
|
tfm = self.sox.Transformer()
|
|
|
|
tfm.set_globals(multithread=False)
|
|
|
|
tfm.set_globals(multithread=False)
|
|
|
|
tfm.speed(ratio)
|
|
|
|
tfm.speed(ratio)
|
|
|
|
y = tfm.build_array(input_array=x, sample_rate_in=self.sr)
|
|
|
|
y = tfm.build_array(input_array=x, sample_rate_in=self.sr)
|
|
|
|