mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
428 lines
24 KiB
HTML
428 lines
24 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Prepare · {{ pending.original_filename }}{% endblock %}
|
|
|
|
{% set is_multi_speaker = pending.speaker_mode == 'multi' %}
|
|
{% set analysis = pending.speaker_analysis or {} %}
|
|
{% set analysis_speakers = analysis.get('speakers', {}) %}
|
|
{% set speaker_configs = options.speaker_configs or [] %}
|
|
{% set recommended_template = options.speaker_pronunciation_sentence or "This is {{name}} speaking." %}
|
|
|
|
{% block content %}
|
|
<section class="wizard-page" data-step="speakers">
|
|
<div class="wizard-card card card--modal">
|
|
<header class="modal__header wizard-card__header">
|
|
<div class="wizard-card__headline">
|
|
<nav class="step-indicator" aria-label="Audiobook workflow">
|
|
<button type="button"
|
|
class="step-indicator__item is-complete"
|
|
data-role="open-upload-modal">
|
|
<span class="step-indicator__index">1</span>
|
|
<span class="step-indicator__label">Upload & settings</span>
|
|
</button>
|
|
<a class="step-indicator__item is-complete"
|
|
href="{{ url_for('web.prepare_job', pending_id=pending.id, step='chapters') }}">
|
|
<span class="step-indicator__index">2</span>
|
|
<span class="step-indicator__label">Chapters</span>
|
|
</a>
|
|
{% if is_multi_speaker %}
|
|
<a class="step-indicator__item is-active"
|
|
aria-current="step"
|
|
href="{{ url_for('web.prepare_job', pending_id=pending.id, step='speakers') }}">
|
|
<span class="step-indicator__index">3</span>
|
|
<span class="step-indicator__label">Speakers</span>
|
|
</a>
|
|
{% endif %}
|
|
</nav>
|
|
<h2 class="modal__title">Select speakers</h2>
|
|
<p class="hint">Assign voices, audition samples, and finalise your roster before queueing the conversion.</p>
|
|
</div>
|
|
<div class="wizard-card__aside">
|
|
<p class="wizard-card__filename" title="{{ pending.original_filename }}">{{ pending.original_filename }}</p>
|
|
</div>
|
|
</header>
|
|
|
|
<form method="post"
|
|
action="{{ url_for('web.finalize_job', pending_id=pending.id) }}"
|
|
class="prepare-form"
|
|
id="prepare-form"
|
|
data-speaker-mode="{{ pending.speaker_mode }}"
|
|
data-analyze-url="{{ url_for('web.analyze_pending_job', pending_id=pending.id) }}">
|
|
<input type="hidden" name="active_step" value="speakers" data-role="active-step-input">
|
|
|
|
<div class="wizard-hidden-inputs" aria-hidden="true">
|
|
<input type="hidden" name="chunk_level" value="{{ pending.chunk_level }}">
|
|
<input type="hidden" name="speaker_mode" value="{{ pending.speaker_mode }}">
|
|
<input type="hidden" name="speaker_analysis_threshold" value="{{ pending.speaker_analysis_threshold }}">
|
|
<input type="hidden" name="chapter_intro_delay" value="{{ '%.2f'|format(pending.chapter_intro_delay) }}">
|
|
{% if pending.generate_epub3 %}
|
|
<input type="hidden" name="generate_epub3" value="true">
|
|
{% endif %}
|
|
{% for chapter in pending.chapters %}
|
|
{% set selected_option = '__default' %}
|
|
{% if chapter.voice_profile %}
|
|
{% set selected_option = 'profile:' ~ chapter.voice_profile %}
|
|
{% elif chapter.voice %}
|
|
{% set selected_option = 'voice:' ~ chapter.voice %}
|
|
{% elif chapter.voice_formula %}
|
|
{% set selected_option = 'formula' %}
|
|
{% endif %}
|
|
{% if chapter.enabled %}
|
|
<input type="hidden" name="chapter-{{ loop.index0 }}-enabled" value="on">
|
|
{% endif %}
|
|
<input type="hidden" name="chapter-{{ loop.index0 }}-title" value="{{ chapter.title }}">
|
|
<input type="hidden" name="chapter-{{ loop.index0 }}-voice" value="{{ selected_option }}">
|
|
{% if chapter.voice_formula %}
|
|
<input type="hidden" name="chapter-{{ loop.index0 }}-formula" value="{{ chapter.voice_formula }}">
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<div class="modal__body wizard-card__body">
|
|
{% if error %}
|
|
<div class="alert alert--error">{{ error }}</div>
|
|
{% endif %}
|
|
{% if notice %}
|
|
<div class="alert alert--info">{{ notice }}</div>
|
|
{% elif pending.speaker_mode != 'multi' %}
|
|
<div class="alert alert--info">Multi-speaker mode is disabled. Switch back to chapters to enable additional voices.</div>
|
|
{% endif %}
|
|
|
|
<section class="prepare-speaker-config">
|
|
<div class="prepare-speaker-config__header">
|
|
<h2>Speaker configuration</h2>
|
|
<p class="hint">Reuse saved presets to keep character voices consistent between projects.</p>
|
|
</div>
|
|
<div class="prepare-speaker-config__grid">
|
|
<label class="field prepare-speaker-config__field" for="applied_speaker_config">
|
|
<span>Saved preset</span>
|
|
<select id="applied_speaker_config" name="applied_speaker_config">
|
|
<option value="">None</option>
|
|
{% for config in speaker_configs %}
|
|
<option value="{{ config.name }}" {% if pending.applied_speaker_config == config.name %}selected{% endif %}>
|
|
{{ config.name }} · {{ config.speakers|length }} speaker{% if config.speakers|length != 1 %}s{% endif %}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
<p class="hint">Presets are managed on the <a href="{{ url_for('web.speaker_configs_page') }}">Speakers page</a>.</p>
|
|
</label>
|
|
<div class="prepare-speaker-config__actions">
|
|
<button type="submit"
|
|
class="button button--ghost"
|
|
name="apply_speaker_config"
|
|
data-role="submit-speaker-analysis"
|
|
value="1"
|
|
formaction="{{ url_for('web.analyze_pending_job', pending_id=pending.id) }}"
|
|
formmethod="post"
|
|
formnovalidate
|
|
{% if not speaker_configs %}disabled{% endif %}>
|
|
Apply preset
|
|
</button>
|
|
<label class="toggle-pill">
|
|
<input type="checkbox" name="save_speaker_config" value="1">
|
|
<span>Save roster updates back to preset</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
{% if pending.speakers %}
|
|
<div class="prepare-speakers">
|
|
<h2>Speaker settings</h2>
|
|
<p class="hint">Set pronunciations, lock specific voices, and audition sample paragraphs to hear casting choices.</p>
|
|
<ul class="speaker-list">
|
|
{% for speaker_id, speaker in pending.speakers.items() %}
|
|
{% set pronunciation_text = speaker.pronunciation or speaker.label %}
|
|
{% set selected_voice = speaker.resolved_voice or speaker.voice %}
|
|
{% set seen = namespace(values=[]) %}
|
|
{% set sample_quotes = speaker.sample_quotes or [] %}
|
|
{% set detected_gender = speaker.detected_gender or speaker.gender or 'unknown' %}
|
|
{% set current_gender = speaker.gender or detected_gender %}
|
|
{% set gender_label = 'Either' if current_gender == 'either' else (current_gender|title if current_gender != 'unknown' else 'Unknown') %}
|
|
{% set detected_label = 'Either' if detected_gender == 'either' else (detected_gender|title if detected_gender != 'unknown' else 'Unknown') %}
|
|
<li class="speaker-list__item"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-default-pronunciation="{{ pronunciation_text }}">
|
|
<div class="speaker-line speaker-list__header">
|
|
<span class="speaker-list__name">{{ speaker.label }}</span>
|
|
<button type="button"
|
|
class="icon-button speaker-list__preview"
|
|
data-role="speaker-preview"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-preview-source="pronunciation"
|
|
data-preview-text="{{ pronunciation_text|e }}"
|
|
data-language="{{ pending.language }}"
|
|
data-voice="{{ selected_voice or pending.voice }}"
|
|
data-speed="{{ '%.2f'|format(pending.speed) }}"
|
|
data-use-gpu="{{ 'true' if pending.use_gpu else 'false' }}"
|
|
aria-label="Preview pronunciation for {{ speaker.label }}"
|
|
title="Preview pronunciation">
|
|
🔊
|
|
</button>
|
|
</div>
|
|
<template data-role="speaker-samples">{{ sample_quotes | tojson }}</template>
|
|
<div class="speaker-list__meta">
|
|
<div class="speaker-gender" data-role="speaker-gender" data-speaker-id="{{ speaker_id }}">
|
|
<button type="button"
|
|
class="chip speaker-gender__pill"
|
|
data-role="gender-pill"
|
|
data-current="{{ current_gender }}">
|
|
{{ gender_label }} voice
|
|
</button>
|
|
<div class="speaker-gender__menu" data-role="gender-menu" hidden>
|
|
<p class="hint">Detected: {{ detected_label }}</p>
|
|
<div class="speaker-gender__options">
|
|
<button type="button" class="chip" data-role="gender-option" data-value="female">Female</button>
|
|
<button type="button" class="chip" data-role="gender-option" data-value="male">Male</button>
|
|
<button type="button" class="chip" data-role="gender-option" data-value="either">Either</button>
|
|
<button type="button" class="chip" data-role="gender-option" data-value="{{ detected_gender }}" {% if detected_gender == current_gender %}data-state="active"{% endif %}>
|
|
Use detected ({{ detected_label }})
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<input type="hidden" name="speaker-{{ speaker_id }}-gender" value="{{ current_gender }}" data-role="gender-input">
|
|
<input type="hidden" name="speaker-{{ speaker_id }}-detected-gender" value="{{ detected_gender }}">
|
|
</div>
|
|
{% if speaker.get('analysis_count') %}
|
|
<span class="badge badge--muted">{{ speaker.analysis_count }} lines · {{ speaker.analysis_confidence|default('low')|title }} confidence</span>
|
|
{% endif %}
|
|
</div>
|
|
<label class="speaker-list__field" for="speaker-{{ speaker_id }}-pronunciation">
|
|
<span>Pronunciation</span>
|
|
<input type="text"
|
|
id="speaker-{{ speaker_id }}-pronunciation"
|
|
name="speaker-{{ speaker_id }}-pronunciation"
|
|
value="{{ pronunciation_text }}"
|
|
data-role="speaker-pronunciation"
|
|
placeholder="{{ speaker.label }}">
|
|
</label>
|
|
<div class="speaker-list__controls">
|
|
<div class="speaker-list__selection">
|
|
<label class="speaker-list__field" for="speaker-{{ speaker_id }}-voice">
|
|
<span>Assigned voice</span>
|
|
<select id="speaker-{{ speaker_id }}-voice"
|
|
name="speaker-{{ speaker_id }}-voice"
|
|
data-role="speaker-voice"
|
|
data-default-voice="{{ pending.voice }}">
|
|
<option value="" {% if not selected_voice %}selected{% endif %}>Use narrator voice ({{ pending.voice }})</option>
|
|
<option value="__custom_mix" data-role="custom-mix-option" {% if speaker.voice_formula %}selected{% else %}hidden disabled{% endif %}>
|
|
Custom mix
|
|
</option>
|
|
{% if speaker.recommended_voices %}
|
|
<optgroup label="Recommended">
|
|
{% for voice_id in speaker.recommended_voices[:6] %}
|
|
{% if voice_id not in seen.values %}
|
|
{% set voice_meta = options.voice_catalog_map.get(voice_id) or {} %}
|
|
<option value="{{ voice_id }}" {% if selected_voice == voice_id %}selected{% endif %}>
|
|
{{ voice_meta.display_name or voice_id }} · {{ voice_meta.language_label or voice_id[0]|upper }} · {{ voice_meta.gender or 'Unknown' }}
|
|
</option>
|
|
{% set _ = seen.values.append(voice_id) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
</optgroup>
|
|
{% endif %}
|
|
<optgroup label="All voices">
|
|
{% for voice in options.voice_catalog %}
|
|
{% if voice.id not in seen.values %}
|
|
<option value="{{ voice.id }}"
|
|
{% if selected_voice == voice.id %}selected{% endif %}>
|
|
{{ voice.display_name }} · {{ voice.language_label }} · {{ voice.gender }}
|
|
</option>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</optgroup>
|
|
</select>
|
|
</label>
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="open-voice-browser"
|
|
data-speaker-id="{{ speaker_id }}">
|
|
Browse voices
|
|
</button>
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="generate-voice"
|
|
data-speaker-id="{{ speaker_id }}">
|
|
Generate voice
|
|
</button>
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="speaker-preview"
|
|
data-preview-kind="generated"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-preview-source="generated"
|
|
data-preview-text="{{ pronunciation_text|e }}"
|
|
data-language="{{ pending.language }}"
|
|
data-voice="{{ speaker.voice_formula or selected_voice or pending.voice }}"
|
|
data-speed="{{ '%.2f'|format(pending.speed) }}"
|
|
data-use-gpu="{{ 'true' if pending.use_gpu else 'false' }}"
|
|
{% if not speaker.voice_formula %}hidden{% endif %}>
|
|
Preview generated
|
|
</button>
|
|
</div>
|
|
<div class="speaker-list__mix" data-role="speaker-mix" {% if not speaker.voice_formula %}hidden{% endif %}>
|
|
<span class="tag">Custom mix</span>
|
|
<span data-role="speaker-mix-label">{{ speaker.voice_formula or '' }}</span>
|
|
<div class="speaker-list__mix-actions">
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="speaker-preview"
|
|
data-preview-source="mix"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-preview-text="{{ pronunciation_text|e }}"
|
|
data-language="{{ pending.language }}"
|
|
data-voice="{{ speaker.voice_formula or selected_voice or pending.voice }}"
|
|
data-speed="{{ '%.2f'|format(pending.speed) }}"
|
|
data-use-gpu="{{ 'true' if pending.use_gpu else 'false' }}">
|
|
Preview mix
|
|
</button>
|
|
<button type="button" class="button button--ghost button--small" data-role="clear-mix">Clear</button>
|
|
</div>
|
|
</div>
|
|
<input type="hidden" name="speaker-{{ speaker_id }}-formula" value="{{ speaker.voice_formula or '' }}" data-role="speaker-formula">
|
|
</div>
|
|
<details class="speaker-list__samples" {% if not sample_quotes %}data-state="empty"{% endif %}>
|
|
<summary>Sample paragraphs</summary>
|
|
{% if sample_quotes %}
|
|
{% set first_sample = sample_quotes[0] if sample_quotes|length > 0 else None %}
|
|
{% set first_excerpt = first_sample.excerpt if first_sample is mapping else first_sample %}
|
|
{% set first_hint = first_sample.gender_hint if first_sample is mapping else '' %}
|
|
<article class="speaker-sample" data-role="speaker-sample">
|
|
<p data-role="sample-text">{{ first_excerpt }}</p>
|
|
<p class="hint" data-role="sample-hint" {% if not first_hint %}hidden{% endif %}>{{ first_hint }}</p>
|
|
<div class="speaker-sample__actions">
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="speaker-preview"
|
|
data-preview-source="sample"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-preview-text="{{ first_excerpt }}"
|
|
data-language="{{ pending.language }}"
|
|
data-voice="{{ selected_voice or pending.voice }}"
|
|
data-speed="{{ '%.2f'|format(pending.speed) }}"
|
|
data-use-gpu="{{ 'true' if pending.use_gpu else 'false' }}">
|
|
Preview with assigned voice
|
|
</button>
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="open-voice-browser"
|
|
data-speaker-id="{{ speaker_id }}"
|
|
data-sample-index="0">
|
|
Preview in voice browser
|
|
</button>
|
|
{% if sample_quotes|length > 1 %}
|
|
<button type="button"
|
|
class="button button--ghost button--small"
|
|
data-role="speaker-next-sample">
|
|
Show another example
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
</article>
|
|
{% else %}
|
|
<p class="hint">No paragraphs captured yet. Continue from Step 2 to gather dialogue samples automatically.</p>
|
|
{% endif %}
|
|
</details>
|
|
{% if speaker.recommended_voices %}
|
|
<div class="speaker-list__recommendations">
|
|
<span class="hint">Suggested:</span>
|
|
{% for voice_id in speaker.recommended_voices[:6] %}
|
|
{% set voice_meta = options.voice_catalog_map.get(voice_id) or {} %}
|
|
<button type="button"
|
|
class="chip"
|
|
data-role="recommended-voice"
|
|
data-voice="{{ voice_id }}"
|
|
title="{{ voice_meta.display_name or voice_id }} · {{ voice_meta.language_label or voice_id[0]|upper }} · {{ voice_meta.gender or 'Unknown' }}">
|
|
{{ voice_meta.display_name or voice_id }}
|
|
</button>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
{% else %}
|
|
<p class="hint">No additional speakers detected yet. The narrator voice will be used for all dialogue.</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<footer class="modal__footer wizard-card__footer">
|
|
<div class="wizard-card__footer-actions">
|
|
<a class="button button--ghost" href="{{ url_for('web.prepare_job', pending_id=pending.id, step='chapters') }}">Previous</a>
|
|
<button type="submit" class="button button--ghost" form="cancel-form">Cancel</button>
|
|
</div>
|
|
<div class="wizard-card__footer-actions">
|
|
<button type="submit" class="button">Queue conversion</button>
|
|
</div>
|
|
</footer>
|
|
</form>
|
|
<form method="post" action="{{ url_for('web.cancel_pending_job', pending_id=pending.id) }}" id="cancel-form"></form>
|
|
|
|
<div class="modal" data-role="voice-modal" hidden>
|
|
<div class="modal__overlay" data-role="voice-modal-close" tabindex="-1"></div>
|
|
<div class="modal__content voice-browser" role="dialog" aria-modal="true" aria-labelledby="voice-modal-title">
|
|
<header class="voice-browser__header">
|
|
<h2 id="voice-modal-title">Choose a voice</h2>
|
|
<button type="button" class="icon-button" data-role="voice-modal-close" aria-label="Close voice browser">✕</button>
|
|
</header>
|
|
<div class="voice-browser__body">
|
|
<aside class="voice-browser__filters">
|
|
<label class="field">
|
|
<span>Search</span>
|
|
<input type="search" data-role="voice-modal-search" placeholder="Search by name or language">
|
|
</label>
|
|
<label class="field">
|
|
<span>Language</span>
|
|
<select data-role="voice-modal-language">
|
|
<option value="">All languages</option>
|
|
{% for code, label in options.languages.items() %}
|
|
<option value="{{ code }}">{{ label }} ({{ code|upper }})</option>
|
|
{% endfor %}
|
|
</select>
|
|
</label>
|
|
<div class="voice-browser__gender" role="group" aria-label="Filter by gender">
|
|
<button type="button" class="button button--ghost button--small" data-role="voice-modal-gender" data-value="">All</button>
|
|
<button type="button" class="button button--ghost button--small" data-role="voice-modal-gender" data-value="f">Female</button>
|
|
<button type="button" class="button button--ghost button--small" data-role="voice-modal-gender" data-value="m">Male</button>
|
|
</div>
|
|
<button type="button" class="button button--ghost" data-role="voice-modal-clear">Clear selection</button>
|
|
</aside>
|
|
<section class="voice-browser__catalog" aria-label="Voice catalog">
|
|
<ul class="voice-browser__list" data-role="voice-modal-list"></ul>
|
|
</section>
|
|
<section class="voice-browser__mix" data-role="voice-modal-mix">
|
|
<header class="voice-browser__mix-header">
|
|
<h3>Selected voices</h3>
|
|
<p class="tag" data-role="voice-modal-mix-total">Total weight: 0.00</p>
|
|
</header>
|
|
<div class="voice-browser__mix-list" data-role="voice-modal-mix-list"></div>
|
|
<section class="voice-browser__preview" data-role="voice-modal-preview">
|
|
<h3 data-role="voice-modal-selected-name">Select a voice to preview</h3>
|
|
<p class="tag" data-role="voice-modal-selected-meta"></p>
|
|
<div class="voice-browser__samples" data-role="voice-modal-samples"></div>
|
|
<div class="voice-browser__actions">
|
|
<button type="button" class="button" data-role="voice-modal-apply" disabled>Apply mix</button>
|
|
</div>
|
|
</section>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{% with pending=pending, readonly=True, active_step='speakers' %}
|
|
{% include "partials/upload_modal.html" %}
|
|
{% endwith %}
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
{{ super() }}
|
|
<script id="voice-sample-texts" type="application/json">{{ options.sample_voice_texts | tojson }}</script>
|
|
<script id="voice-catalog-data" type="application/json">{{ options.voice_catalog | tojson }}</script>
|
|
<script id="voice-language-map" type="application/json">{{ options.languages | tojson }}</script>
|
|
<script type="module" src="{{ url_for('static', filename='speakers.js') }}"></script>
|
|
<script type="module" src="{{ url_for('static', filename='prepare.js') }}"></script>
|
|
<script type="module" src="{{ url_for('static', filename='dashboard.js') }}"></script>
|
|
{% endblock %}
|