diff --git a/Cargo.lock b/Cargo.lock
index 445348c..cc1fd2c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -700,7 +700,7 @@ dependencies = [
[[package]]
name = "nexus"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"axum",
"nexus-adapter",
@@ -715,7 +715,7 @@ dependencies = [
[[package]]
name = "nexus-adapter"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"async-trait",
"libc",
@@ -730,7 +730,7 @@ dependencies = [
[[package]]
name = "nexus-api"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"async-trait",
"axum",
@@ -750,7 +750,7 @@ dependencies = [
[[package]]
name = "nexus-core"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"argon2",
"serde",
@@ -761,14 +761,14 @@ dependencies = [
[[package]]
name = "nexus-scheduler"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"nexus-core",
]
[[package]]
name = "nexus-store"
-version = "0.1.15-rc10"
+version = "0.1.15-rc12"
dependencies = [
"nexus-core",
"rusqlite",
diff --git a/Cargo.toml b/Cargo.toml
index cb67611..9bb4d17 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/nexus-core", "crates/nexus-scheduler", "crates/nexus-store", "crates/nexus-adapter", "crates/nexus-api", "crates/nexus"]
[workspace.package]
-version = "0.1.15-rc11"
+version = "0.1.15-rc12"
edition = "2024"
license = "MIT"
repository = "ssh://git@git.wlkns.org:2222/wlkns-dev/nexus.git"
diff --git a/crates/nexus-api/assets/stimmen.js b/crates/nexus-api/assets/stimmen.js
index 654e918..6e8204d 100644
--- a/crates/nexus-api/assets/stimmen.js
+++ b/crates/nexus-api/assets/stimmen.js
@@ -2,27 +2,35 @@
(() => {
const status = document.getElementById('probe-status');
const csrf = document.querySelector('input[name=csrf]')?.value;
+ // Ein einziger Ton-Ausgang für alle Proben, gleich beim ersten Klick geweckt (sonst geht der Anfang verloren
+ // oder die zweite Probe bleibt stumm). Vor dem Ton liegt eine kurze Stille.
+ let ctx = null;
+ const ausgang = () => {
+ if (!ctx || ctx.state === 'closed') ctx = new AudioContext({sampleRate: 24000});
+ if (ctx.state !== 'running') ctx.resume();
+ return ctx;
+ };
document.querySelectorAll('button.probe').forEach(button => button.addEventListener('click', async () => {
- const select = button.parentElement.querySelector('.stimmen-modell');
- const saved = button.dataset.gespeichert === '1';
- const matches = o => o.dataset.art === (saved ? 'gespeichert' : 'eingebaut') || o.dataset.art === 'alle';
- const model = matches(select.selectedOptions[0]) ? select.selectedOptions[0] : Array.from(select.options).find(matches);
- if (!model) { status.textContent = 'Kein passendes installiertes Sprachmodell verfügbar.'; return; }
+ const select = button.closest('tr')?.querySelector('.stimmen-modell');
+ const modell = select ? select.value : button.dataset.modell;
+ if (!modell) { status.textContent = 'Kein passendes installiertes Sprachmodell verfügbar.'; return; }
+ const ton = ausgang();
button.disabled = true;
- status.textContent = 'Probehören wird geladen …';
+ status.textContent = 'Probehören wird geladen (beim ersten Mal kann das einige Sekunden dauern) …';
try {
- const response = await fetch('/ui/modelle/probe', {method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRF-Token': csrf}, credentials: 'same-origin', body: JSON.stringify({model: model.value, voice: button.dataset.stimme})});
+ const response = await fetch('/ui/modelle/probe', {method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRF-Token': csrf}, credentials: 'same-origin', body: JSON.stringify({model: modell, voice: button.dataset.stimme})});
if (!response.ok) throw new Error('Die Stimme konnte nicht probegehört werden.');
// PCM 24 kHz / 16 Bit / Mono, wie bei der bestehenden Vorlese-Route.
const pcm = await response.arrayBuffer();
- const samples = new Int16Array(pcm);
- const ctx = new AudioContext({sampleRate: 24000});
- await ctx.resume();
- const buffer = ctx.createBuffer(1, samples.length, 24000);
+ const samples = new Int16Array(pcm, 0, Math.floor(pcm.byteLength / 2));
+ const vorlauf = Math.round(0.3 * 24000);
+ const buffer = ton.createBuffer(1, vorlauf + samples.length, 24000);
const channel = buffer.getChannelData(0);
- for (let i = 0; i < samples.length; i++) channel[i] = samples[i] / 32768;
- const source = ctx.createBufferSource(); source.buffer = buffer; source.connect(ctx.destination);
- source.onended = () => ctx.close(); source.start();
+ for (let i = 0; i < samples.length; i++) channel[vorlauf + i] = samples[i] / 32768;
+ await ton.resume();
+ const source = ton.createBufferSource(); source.buffer = buffer; source.connect(ton.destination);
+ source.onended = () => { status.textContent = ''; };
+ source.start(ton.currentTime + 0.05);
status.textContent = 'Probehören läuft.';
} catch (_) { status.textContent = 'Die Stimme konnte nicht probegehört werden.'; }
finally { button.disabled = false; }
diff --git a/crates/nexus-api/src/ui/stimmen.rs b/crates/nexus-api/src/ui/stimmen.rs
index 21b5670..b3cccbd 100644
--- a/crates/nexus-api/src/ui/stimmen.rs
+++ b/crates/nexus-api/src/ui/stimmen.rs
@@ -30,23 +30,19 @@ pub(super) async fn page(state: &AppState, user: &super::Viewer) -> String {
let voices = state.runtime.engine_voices("tts").await;
let studio_erreichbar = state.runtime.engine_voices_reachable("tts").await;
let freigegeben = state.store().list_models(true).unwrap_or_default();
- let options: String = freigegeben
+ // Installierte, freigegebene Sprachmodelle mit der Art ihrer Stimmen.
+ let modelle: Vec<(String, &'static str)> = freigegeben
.into_iter()
.filter_map(|m| {
let d = state.store().model_details(&m.name).ok().flatten()?;
if d.engine != "tts" || !crate::ui::chat::speech_offered(&state.runtime, &d.path) {
return None;
}
- Some(format!(
- "",
- esc(&m.name),
- super::chat::voice_art(&d.path),
- esc(&m.name)
- ))
+ Some((m.name, super::chat::voice_art(&d.path)))
})
.collect();
- body.push_str("
Stimmen
Eine Stimme darf ohne Freigabe nur probegehört werden. Die erste Freigabe beansprucht die Stimme für diesen Benutzer.
");
- if options.is_empty() {
+ body.push_str("
Stimmen
Eine Stimme darf ohne Freigabe nur probegehört werden. Die erste Freigabe beansprucht die Stimme für diesen Benutzer. Gespeicherte Stimmen klont ein Base-Modell, eingebaute Stimmen spricht ein CustomVoice-Modell.