mirror of https://gitlab.com/bashrc2/epicyon
playing mimic3 sound
parent
7814fac9ba
commit
250c351355
|
@ -16,7 +16,6 @@ import webbrowser
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from random import randint
|
from random import randint
|
||||||
from subprocess import call
|
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import disallow_announce
|
from utils import disallow_announce
|
||||||
from utils import disallow_reply
|
from utils import disallow_reply
|
||||||
|
@ -327,6 +326,18 @@ def _speaker_espeak(espeak, pitch: int, rate: int, srange: int,
|
||||||
espeak.synth(html.unescape(say_text))
|
espeak.synth(html.unescape(say_text))
|
||||||
|
|
||||||
|
|
||||||
|
def _play_notification_sound(sound_filename: str,
|
||||||
|
player: str = 'ffplay') -> None:
|
||||||
|
"""Plays a sound
|
||||||
|
"""
|
||||||
|
if not os.path.isfile(sound_filename):
|
||||||
|
return
|
||||||
|
|
||||||
|
if player == 'ffplay':
|
||||||
|
os.system('ffplay ' + sound_filename +
|
||||||
|
' -autoexit -hide_banner -nodisp 2> /dev/null')
|
||||||
|
|
||||||
|
|
||||||
def _speaker_mimic3(pitch: int, rate: int, srange: int,
|
def _speaker_mimic3(pitch: int, rate: int, srange: int,
|
||||||
say_text: str) -> None:
|
say_text: str) -> None:
|
||||||
"""Speaks the given text with mimic3
|
"""Speaks the given text with mimic3
|
||||||
|
@ -348,13 +359,13 @@ def _speaker_mimic3(pitch: int, rate: int, srange: int,
|
||||||
audio_filename = '/tmp/epicyon_voice.wav'
|
audio_filename = '/tmp/epicyon_voice.wav'
|
||||||
cmd = 'mimic3 -v ' + voice + \
|
cmd = 'mimic3 -v ' + voice + \
|
||||||
' --length-scale ' + length_scale + \
|
' --length-scale ' + length_scale + \
|
||||||
' --noise-w ' + noise_w + ' --stdout' + \
|
' --noise-w ' + noise_w + \
|
||||||
' "' + text + '" > ' + audio_filename
|
' "' + text + '" > ' + audio_filename
|
||||||
try:
|
try:
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
call(['aplay', audio_filename])
|
except OSError as ex:
|
||||||
except OSError:
|
print('EX: unable to play ' + audio_filename + ' ' + str(ex))
|
||||||
print('EX: unable to play ' + audio_filename)
|
_play_notification_sound(audio_filename)
|
||||||
|
|
||||||
|
|
||||||
def _speaker_picospeaker(pitch: int, rate: int, system_language: str,
|
def _speaker_picospeaker(pitch: int, rate: int, system_language: str,
|
||||||
|
@ -381,18 +392,6 @@ def _speaker_picospeaker(pitch: int, rate: int, system_language: str,
|
||||||
os.system(speaker_cmd)
|
os.system(speaker_cmd)
|
||||||
|
|
||||||
|
|
||||||
def _play_notification_sound(sound_filename: str,
|
|
||||||
player: str = 'ffplay') -> None:
|
|
||||||
"""Plays a sound
|
|
||||||
"""
|
|
||||||
if not os.path.isfile(sound_filename):
|
|
||||||
return
|
|
||||||
|
|
||||||
if player == 'ffplay':
|
|
||||||
os.system('ffplay ' + sound_filename +
|
|
||||||
' -autoexit -hide_banner -nodisp 2> /dev/null')
|
|
||||||
|
|
||||||
|
|
||||||
def _desktop_notification(notification_type: str,
|
def _desktop_notification(notification_type: str,
|
||||||
title: str, message: str) -> None:
|
title: str, message: str) -> None:
|
||||||
"""Shows a desktop notification
|
"""Shows a desktop notification
|
||||||
|
|
Loading…
Reference in New Issue