Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def text_to_speach(text):
- with open(join(dirname(__file__),'resources/text.wav'),
- 'wb') as audio_file:
- audio_file.write(
- text_to_speech.synthesize(str(text), accept='audio/wav',
- voice="en-US_AllisonVoice"))
- createjs.Sound.on("fileload", this.loadHandler, this);
- function loadHandler(event) {
- createjs.Sound.play("x");
- }
- socket.onmessage = function(e) {
- createjs.Sound.registerSound("resources/text.wav", "x"); // регистрирую файл
- loadHandler() // вызываю функцию для воспроизведения
- }
- function initialHandler(event) {
- Voice = "resources/" + data.filename + ".wav";
- playHandler();
- }
- function registerHandler() {
- createjs.Sound.registerSound(Voice);
- createjs.Sound.on("fileload", playHandler);
- }
- function playHandler() {
- if(createjs.Sound.loadComplete(Voice)) {
- createjs.Sound.play(Voice);
- } else {
- registerHandler()
- }
- }
- file_path = join(dirname(__file__),'resources/{}.wav'.format(filename))
- if not os.path.exists(file_path):
- with open(file_path, 'wb') as audio_file:
- audio_file.write(
- text_to_speech.synthesize(str(text),
- accept='audio/wav',
- voice="en-US_AllisonVoice")
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement