Compare commits
2 commits
23dda2fe90
...
c26e7bf48b
Author | SHA1 | Date | |
---|---|---|---|
c26e7bf48b | |||
6f63cf06f9 |
2 changed files with 11 additions and 4 deletions
|
@ -8,6 +8,8 @@ from ovtk_audiencekit.core import Clip, Stream
|
|||
|
||||
class AudioAlert(PluginBase):
|
||||
def setup(self, output=None, timeout_min=1, sample_rate=None, buffer_length=4096, force_stereo=True):
|
||||
self._cleanup_task = asyncio.create_task(self._cleanup())
|
||||
|
||||
self.force_stereo = force_stereo
|
||||
self.timeout_min = timeout_min
|
||||
self.clips = {}
|
||||
|
@ -20,8 +22,7 @@ class AudioAlert(PluginBase):
|
|||
sample_rate = next((rate for rate in [44100, 48000] if Stream.check_rate(self.output_index, 1, rate)))
|
||||
except StopIteration:
|
||||
self.logger.warn('Target audio device does not claim to support common sample rates! Attempting playback at native rate of audio')
|
||||
|
||||
self._cleanup_task = asyncio.create_task(self._cleanup())
|
||||
self.sample_rate = sample_rate
|
||||
|
||||
def run(self, path, speed=1, keep_pitch=False, immediate=True, poly=1, **kwargs):
|
||||
poly = int(poly)
|
||||
|
@ -29,7 +30,8 @@ class AudioAlert(PluginBase):
|
|||
clip = self.clips.get(key, [None, None])[0]
|
||||
|
||||
if clip is None:
|
||||
clip = Clip(path, speed=speed, keep_pitch=keep_pitch, force_stereo=self.force_stereo)
|
||||
clip = Clip(path, speed=speed, keep_pitch=keep_pitch,
|
||||
samplerate=self.sample_rate, force_stereo=self.force_stereo)
|
||||
self.clips[key] = [clip, maya.now()]
|
||||
else:
|
||||
self.clips[key][1] = maya.now()
|
||||
|
|
|
@ -19,6 +19,11 @@ class TextToSpeechPlugin(PluginBase):
|
|||
self.speaker_wav = speaker_wav
|
||||
|
||||
self.output_index = Stream.find_output_index(output)
|
||||
try:
|
||||
sample_rate = next((rate for rate in [44100, 48000] if Stream.check_rate(self.output_index, 1, rate)))
|
||||
except StopIteration:
|
||||
self.logger.warn('Target audio device does not claim to support common sample rates! Attempting playback at native rate of audio')
|
||||
self.sample_rate = sample_rate
|
||||
|
||||
conf_overrides = {k[2:]: v for k, v in kwargs.items() if k.startswith('o_')}
|
||||
|
||||
|
@ -72,7 +77,7 @@ class TextToSpeechPlugin(PluginBase):
|
|||
text += '.'
|
||||
filename = self.make_tts_wav(text)
|
||||
# TODO: Play direct from memory
|
||||
clip = Clip(filename, force_stereo=True)
|
||||
clip = Clip(filename, force_stereo=True, samplerate=self.sample_rate)
|
||||
stream = Stream(clip, self.output_index)
|
||||
if wait:
|
||||
async def play():
|
||||
|
|
Loading…
Add table
Reference in a new issue