feat: Add stubs for soundfile and static_ffmpeg modules to facilitate testing

This commit is contained in:
JB
2025-11-11 17:00:58 -08:00
parent 504b5ab5e5
commit 028384e6ee
9 changed files with 424 additions and 54 deletions
+3
View File
@@ -2095,6 +2095,7 @@ BOOLEAN_SETTINGS = {
"normalization_titles",
"normalization_terminal",
"normalization_phoneme_hints",
"normalization_caps_quotes",
"normalization_apostrophes_contractions",
"normalization_apostrophes_plural_possessives",
"normalization_apostrophes_sibilant_possessives",
@@ -2123,6 +2124,7 @@ _APOSTROPHE_OVERRIDE_KEYS = (
"normalization_contraction_modal_would",
"normalization_contraction_negation_not",
"normalization_contraction_let_us",
"normalization_caps_quotes",
)
@@ -2192,6 +2194,7 @@ def _settings_defaults() -> Dict[str, Any]:
"normalization_titles": True,
"normalization_terminal": True,
"normalization_phoneme_hints": True,
"normalization_caps_quotes": True,
"normalization_apostrophes_contractions": True,
"normalization_apostrophes_plural_possessives": True,
"normalization_apostrophes_sibilant_possessives": True,
+24 -3
View File
@@ -116,9 +116,30 @@
body: JSON.stringify(payload),
});
const data = await response.json();
if (!response.ok || data.error) {
throw new Error(data.error || 'Preview failed.');
const contentType = response.headers.get('Content-Type') || '';
let data = null;
if (contentType.includes('application/json')) {
try {
data = await response.json();
} catch (parseError) {
if (!response.ok) {
throw new Error('Preview failed.');
}
throw parseError instanceof Error ? parseError : new Error('Preview failed.');
}
} else {
if (!response.ok) {
const fallback = await response.text().catch(() => '');
throw new Error(fallback || 'Preview failed.');
}
throw new Error('Preview failed.');
}
if (!response.ok || (data && data.error)) {
throw new Error((data && data.error) || 'Preview failed.');
}
if (!data || typeof data !== 'object') {
throw new Error('Preview failed.');
}
if (!data.audio_base64) {
throw new Error('Preview did not return audio.');
+47 -9
View File
@@ -108,9 +108,19 @@
<span>Voice override</span>
<select name="voice">
<option value="" selected>No override</option>
{% for voice in options.voice_catalog %}
<option value="{{ voice.id }}">{{ voice.display_name }} - {{ voice.language_label }} - {{ voice.gender }}</option>
{% endfor %}
{% if options.voice_profile_options %}
<optgroup label="Saved mixes">
{% for profile in options.voice_profile_options %}
{% set profile_value = 'profile:' ~ profile.name %}
<option value="{{ profile_value }}">{{ profile.name }}{% if profile.language %} · {{ profile.language|upper }}{% endif %}</option>
{% endfor %}
</optgroup>
{% endif %}
<optgroup label="Stock voices">
{% for voice in options.voice_catalog %}
<option value="{{ voice.id }}">{{ voice.display_name }} - {{ voice.language_label }} - {{ voice.gender }}</option>
{% endfor %}
</optgroup>
</select>
</label>
</div>
@@ -166,17 +176,45 @@
>
</td>
<td data-label="Voice">
{% set current_voice = override.voice or '' %}
{% set known_voice = namespace(value=False) %}
{% if current_voice %}
{% if current_voice in options.voice_catalog_map %}
{% set known_voice.value = True %}
{% else %}
{% for profile in options.voice_profile_options %}
{% if current_voice == 'profile:' ~ profile.name %}
{% set known_voice.value = True %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
<select
class="overrides-table__select"
name="voice"
form="{{ form_id }}"
>
<option value="" {% if not override.voice %}selected{% endif %}>No override</option>
{% for voice in options.voice_catalog %}
<option value="{{ voice.id }}" {% if override.voice == voice.id %}selected{% endif %}>
{{ voice.display_name }} - {{ voice.language_label }} - {{ voice.gender }}
</option>
{% endfor %}
<option value="" {% if not current_voice %}selected{% endif %}>No override</option>
{% if options.voice_profile_options %}
<optgroup label="Saved mixes">
{% for profile in options.voice_profile_options %}
{% set profile_value = 'profile:' ~ profile.name %}
<option value="{{ profile_value }}" {% if current_voice == profile_value %}selected{% endif %}>
{{ profile.name }}{% if profile.language %} · {{ profile.language|upper }}{% endif %}
</option>
{% endfor %}
</optgroup>
{% endif %}
<optgroup label="Stock voices">
{% for voice in options.voice_catalog %}
<option value="{{ voice.id }}" {% if current_voice == voice.id %}selected{% endif %}>
{{ voice.display_name }} - {{ voice.language_label }} - {{ voice.gender }}
</option>
{% endfor %}
</optgroup>
{% if current_voice and not known_voice.value %}
<option value="{{ current_voice }}" selected>{{ current_voice }}</option>
{% endif %}
</select>
</td>
<td data-label="Usage">{{ override.usage_count }}</td>
@@ -127,7 +127,12 @@
{% set narrator_voice = '' %}
{% endif %}
{% set normalization_overrides = pending.normalization_overrides if pending and pending.normalization_overrides else {} %}
{% set apostrophe_toggles = [
{% set normalization_toggles = [
{
'name': 'normalization_caps_quotes',
'label': "Convert ALL CAPS dialogue inside quotes",
'value': normalization_overrides.get('normalization_caps_quotes', settings_dict.get('normalization_caps_quotes', True)),
},
{
'name': 'normalization_apostrophes_contractions',
'label': "Expand contractions (it's -> it is)",
@@ -298,7 +303,7 @@
<section class="form-section">
<h3 class="form-section__title">Text normalization</h3>
<div class="field-grid field-grid--compact">
{% for toggle in apostrophe_toggles %}
{% for toggle in normalization_toggles %}
<div class="field field--stack">
<label class="toggle-pill">
<input type="hidden" name="{{ toggle.name }}" value="false">
+4
View File
@@ -302,6 +302,10 @@
<input type="checkbox" name="normalization_phoneme_hints" value="true" {% if settings.normalization_phoneme_hints %}checked{% endif %}>
<span>Add phoneme hints for possessives</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_caps_quotes" value="true" {% if settings.normalization_caps_quotes %}checked{% endif %}>
<span>Convert ALL CAPS dialogue inside quotes</span>
</label>
<span class="field__caption">Apostrophes</span>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_contractions" value="true" {% if settings.normalization_apostrophes_contractions %}checked{% endif %}>