Skip to content

Clone your own voice on your own computer: speak any text in 60+ languages and dub videos into another language in your voice. Fully local. Early version.

5.2 KB
Raw Blame
pub mod api;
pub mod book;
pub mod caption;
pub mod components;
pub mod design;
pub mod events;
pub mod ffmpeg;
pub mod formats;
pub mod history;
pub mod lang;
pub mod modules;
pub mod onboarding;
pub mod photos;
pub mod playbar;
pub mod record;
pub mod redub;
pub mod refclip;
pub mod refmedia;
pub mod relocate;
#[cfg(windows)]
pub mod seekstrip;
pub mod settings;
pub mod setuprun;
pub mod shell;
pub mod speak;
pub mod stats;
pub mod theme;
pub mod train;
pub mod trash;
pub mod update;
pub mod video;
pub mod voiceimport;
pub mod voices;
pub mod winplace;

use crate::state::AppState;
use rune::{Cx, El, KeyEvent, Tx};
use std::sync::OnceLock;

pub fn view(s: &AppState, cx: &mut Cx<AppState>) -> El {
    stats::count(&stats::VIEWS);
    shell::view(s, cx)
}

/// Named states for headless snapshots (`--snap out.png --scene <name>`).
pub const SCENES: &[Scene] = &[
    ("record_picker", record::scene_picker),
    ("record_new_voice", record::scene_new_voice),
    ("record_files_hover", record::scene_files_hover),
    ("record_files_ask", record::scene_files_ask),
    ("record_files_working", record::scene_files_working),
    ("record_files_done", record::scene_files_done),
    ("record_own_text", record::scene_own_text),
    ("record_language_uk", record::scene_language_uk),
    ("record_language_menu", record::scene_language_menu),
    ("record_other_language", record::scene_other_language),
    ("record_session_uk", record::scene_session_uk),
    ("record_own_text_uk", record::scene_own_text_uk),
    ("record_recording", record::scene_recording),
    ("record_recording_loud", record::scene_recording_loud),
    ("record_saved", record::scene_notice_saved),
    ("record_saved_issues", record::scene_saved_with_issues),
    ("record_rejected", record::scene_rejected),
    ("record_summary_ready", record::scene_summary_ready),
    ("record_quick_ready", record::scene_quick_ready),
    ("record_mic_picker", record::scene_mic_picker),
    ("record_mic_open", record::scene_mic_open),
    ("record_mic_warning", record::scene_mic_warning),
    ("record_import_drop", record::scene_import_drop),
    ("record_import_checking", record::scene_import_checking),
    ("record_import_saved", record::scene_import_saved),
    ("speak_idle", speak::scene_idle),
    ("speak_typed", speak::scene_typed),
    ("speak_language_uk", speak::scene_language_uk),
    ("speak_language_uk_no_extension", speak::scene_language_uk_no_extension),
    ("speak_language_picker", speak::scene_language_picker),
    ("speak_models", speak::scene_models),
    ("speak_model_menu", speak::scene_model_menu),
    ("speak_model_unsupported", speak::scene_model_unsupported),
    ("speak_accent_native", speak::scene_accent_native),
    ("speak_accent_own", speak::scene_accent_own),
    ("speak_accent_untrained", speak::scene_accent_untrained),
    ("speak_accent_zero_shot", speak::scene_accent_zero_shot),
    ("speak_accent_foreign_ref", speak::scene_accent_foreign_ref),
    ("speak_accent_foreign_ref_zero_shot", speak::scene_accent_foreign_ref_zero_shot),
    ("speak_accent_foreign_ref_trained", speak::scene_accent_foreign_ref_trained),
    ("speak_generating", speak::scene_generating),
    ("speak_buffering", speak::scene_buffering),
    ("speak_preparing", speak::scene_preparing),
    ("speak_done", speak::scene_done),
    ("speak_history", speak::scene_history),
    ("speak_trash_confirm", speak::scene_trash_confirm),
    ("speak_toast_long", speak::scene_toast_long),
    ("speak_export_menu", speak::scene_export_menu),
    ("speak_export_video", speak::scene_export_video),
    ("speak_output_menu", speak::scene_output_menu),
    ("move_confirm", relocate::scene_confirm),
    ("move_running", relocate::scene_running),
    ("move_failed", relocate::scene_failed),
    ("speak_no_voice", speak::scene_no_voice),
    ("engine_starting", speak::scene_engine_starting),
    ("engine_stopped", speak::scene_engine_stopped),
    ("engine_no_memory", speak::scene_engine_no_memory),
    ("engine_models_missing", speak::scene_engine_models_missing),
];

type Scene = (&'static str, fn(&mut AppState));

pub fn all_scenes() -> &'static [Scene] {
    static ALL: OnceLock<Vec<Scene>> = OnceLock::new();
    ALL.get_or_init(|| {
        let mut all: Vec<Scene> = SCENES.to_vec();
        all.extend_from_slice(caption::scenes());
        all.extend_from_slice(onboarding::scenes());
        all.extend_from_slice(voices::scenes());
        all.extend_from_slice(voiceimport::scenes());
        all.extend_from_slice(refclip::scenes());
        all.extend_from_slice(refmedia::scenes());
        all.extend_from_slice(train::scenes());
        all.extend_from_slice(redub::scenes());
        all.extend_from_slice(playbar::scenes());
        all.extend_from_slice(book::scenes());
        all.extend_from_slice(update::scenes());
        all.extend_from_slice(settings::scenes());
        all.extend_from_slice(design::scenes());
        all
    })
}

pub fn on_focus(s: &mut AppState, focused: bool, _tx: &mut Tx) {
    if focused {
        onboarding::on_focus(s);
    }
}

/// Each screen gets a chance in turn; the first to take the key wins.
pub fn on_key(s: &mut AppState, ev: &KeyEvent, tx: &mut Tx) -> bool {
    record::on_key(s, ev, tx) || speak::on_key(s, ev, tx) || playbar::on_window_key(s, ev, tx)
}