Compare commits
4 commits
a63730fe86
...
11b4c92fe9
Author | SHA1 | Date | |
---|---|---|---|
11b4c92fe9 | |||
32fc1660ec | |||
4b5dd0cf43 | |||
ba0b8c1068 |
5 changed files with 19 additions and 6 deletions
|
@ -55,7 +55,7 @@ class Clip:
|
|||
if keep_pitch:
|
||||
stretched = tsm.wsola(self._stereo_transpose(self.raw), speed)
|
||||
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')
|
||||
|
||||
def save(self, filename):
|
||||
|
|
|
@ -29,6 +29,17 @@ class OvtkBlueprint(quart.Blueprint):
|
|||
endpoint = self.name + endpoint
|
||||
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):
|
||||
plugins = {}
|
||||
|
|
|
@ -66,6 +66,11 @@ class TextToSpeechPlugin(PluginBase):
|
|||
task.cancel()
|
||||
|
||||
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:
|
||||
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):
|
||||
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
|
||||
filename = await asyncio.get_running_loop().run_in_executor(None, self.make_tts_wav, text)
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class ScenePlugin(PluginBase):
|
|||
|
||||
async def ui_ctrlpanel(self):
|
||||
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):
|
||||
active = cmd == 'activate'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test page</title>
|
||||
<title>Scene control</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" }
|
||||
|
|
Loading…
Add table
Reference in a new issue