made dec talk work again, fixed so pitch and tempo can work with random chosen, example playb, train

This commit is contained in:
jenz 2024-08-05 21:37:42 +02:00
parent dc8b4badd0
commit e29eb32a91
3 changed files with 8 additions and 6 deletions

View File

@ -303,8 +303,8 @@ class AudioClip():
def __del__(self): def __del__(self):
self.Logger.info("~AudioClip()") self.Logger.info("~AudioClip()")
def Play(self, seconds = None, rubberband = None, *args): def Play(self, seconds = None, rubberband = None, dec_params = None, *args):
return self.AudioPlayer.PlayURI(self.URI, seconds, rubberband = rubberband, *args) return self.AudioPlayer.PlayURI(self.URI, position = seconds, rubberband = rubberband, dec_params = dec_params, *args)
def Stop(self): def Stop(self):
return self.AudioPlayer.Stop() return self.AudioPlayer.Stop()

View File

@ -561,8 +561,7 @@ class VoiceCommands(BaseCommand):
if isinstance(Sounds, list): if isinstance(Sounds, list):
if Num and Num > 0 and Num <= len(Sounds): if Num and Num > 0 and Num <= len(Sounds):
Sound = Sounds[Num - 1] Sound = Sounds[Num - 1]
elif message[1] and message[1][0].isdigit(): #first character is digit, so its not pitch or tempo
elif message[1]:
searching = message[1].startswith('?') searching = message[1].startswith('?')
search = message[1][1:] if searching else message[1].split(" ")[0] search = message[1][1:] if searching else message[1].split(" ")[0]
Sound = None Sound = None
@ -752,7 +751,7 @@ class DECTalk(BaseCommand):
os.unlink(TempFile.name) os.unlink(TempFile.name)
return 1 return 1
if AudioClip.Play(None, "-af", "volume=10dB"): if AudioClip.Play(dec_params = ["-af", "volume=10dB"]):
AudioClip.AudioPlayer.AddCallback("Stop", lambda: os.unlink(TempFile.name)) AudioClip.AudioPlayer.AddCallback("Stop", lambda: os.unlink(TempFile.name))
return 0 return 0
else: else:

View File

@ -57,7 +57,7 @@ class FFmpegAudioPlayer():
self.Master.Logger.debug("~FFmpegAudioPlayer()") self.Master.Logger.debug("~FFmpegAudioPlayer()")
self.Stop() self.Stop()
def PlayURI(self, uri, position, rubberband = None, *args): def PlayURI(self, uri, position, rubberband = None, dec_params = None, *args):
if position: if position:
PosStr = str(datetime.timedelta(seconds = position)) PosStr = str(datetime.timedelta(seconds = position))
Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args] Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args]
@ -65,6 +65,9 @@ class FFmpegAudioPlayer():
Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args] Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args]
self.Playing = True self.Playing = True
if dec_params:
Command += dec_params
if rubberband: if rubberband:
Command += ["-filter:a"] Command += ["-filter:a"]
rubberCommand = "" rubberCommand = ""