Compare commits

..

4 commits

5 changed files with 19 additions and 6 deletions

View file

@ -55,7 +55,7 @@ class Clip:
if keep_pitch: if keep_pitch:
stretched = tsm.wsola(self._stereo_transpose(self.raw), speed) stretched = tsm.wsola(self._stereo_transpose(self.raw), speed)
else: else:
stretched = librosa.resample(self._stereo_transpose(self.raw), self.samplerate * (1 / speed), self.samplerate, fix=False, scale=True) stretched = librosa.resample(self._stereo_transpose(self.raw), self.samplerate * speed, self.samplerate, fix=False, scale=True)
self.raw = np.ascontiguousarray(self._stereo_transpose(stretched), dtype='float32') self.raw = np.ascontiguousarray(self._stereo_transpose(stretched), dtype='float32')
def save(self, filename): def save(self, filename):

View file

@ -29,6 +29,17 @@ class OvtkBlueprint(quart.Blueprint):
endpoint = self.name + endpoint endpoint = self.name + endpoint
return quart.url_for(endpoint, *args, **kwargs) return quart.url_for(endpoint, *args, **kwargs)
def render(self, name, **kwargs):
"""render_template that prefers the plugin-specific templates"""
full = self.template_folder / name
if os.path.exists(full):
template_string = None
with open(full, 'r') as template_file:
template_string = template_file.read()
return quart.render_template_string(template_string, **kwargs)
else:
return quart.render_template(name, **kwargs)
class PluginBase(ABC): class PluginBase(ABC):
plugins = {} plugins = {}

View file

@ -66,6 +66,11 @@ class TextToSpeechPlugin(PluginBase):
task.cancel() task.cancel()
def make_tts_wav(self, text, filename=None): def make_tts_wav(self, text, filename=None):
# Force punctuation (keeps the models from acting unpredictably)
text = text.strip()
if not any([text.endswith(punc) for punc in '.!?:']):
text += '.'
if filename is None: if filename is None:
filename = os.path.join(self.cache_dir, f'{uuid.uuid1()}.wav') filename = os.path.join(self.cache_dir, f'{uuid.uuid1()}.wav')
@ -79,9 +84,6 @@ class TextToSpeechPlugin(PluginBase):
async def run(self, text, *args, _ctx={}, wait=False, **kwargs): async def run(self, text, *args, _ctx={}, wait=False, **kwargs):
try: try:
# Force punctuation (keep AI from spinning off into random noises)
if not any([text.endswith(punc) for punc in '.!?:']):
text += '.'
# Do TTS processing in a thread to avoid blocking main loop # Do TTS processing in a thread to avoid blocking main loop
filename = await asyncio.get_running_loop().run_in_executor(None, self.make_tts_wav, text) filename = await asyncio.get_running_loop().run_in_executor(None, self.make_tts_wav, text)

View file

@ -138,7 +138,7 @@ class ScenePlugin(PluginBase):
async def ui_ctrlpanel(self): async def ui_ctrlpanel(self):
groups = self._get_state() groups = self._get_state()
return await quart.render_template('index.html', init_state=json.dumps(groups)) return await self.blueprint.render('index.html', init_state=json.dumps(groups))
async def ui_setscene(self, name=None, cmd=None): async def ui_setscene(self, name=None, cmd=None):
active = cmd == 'activate' active = cmd == 'activate'

View file

@ -2,7 +2,7 @@
<html lang="en" dir="ltr"> <html lang="en" dir="ltr">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Test page</title> <title>Scene control</title>
<script type="importmap"> <script type="importmap">
{ {
"imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" } "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" }