Preview voice profile edits and confirm profiles from their tab

This commit is contained in:
Storm Dragon committed 2026-11-15 18:29:24 -05:00
1 parent e20319f776
commit 317303adb7
12 files changed
+165 -44

No files matched your search

+10 -3
View File
@@ -466,13 +466,20 @@ shows the selected synthesizer's settings. Leaving the name blank generates a
name from the module and voice, or the hardware synthesizer. Duplicate names
are rejected. Edit/Remove update the menu draft; Escape/Cancel in the child
editor returns to the menu without saving that edit. Confirm the parent menu
with **OK** on a settings tab to persist profile changes.
with **OK**, available on the Voice Profiles tab, to save the profiles and make
them available immediately in quick settings. Cancel discards the menu draft.
**Use Voice Profile** loads the profile into the menu's primary speech draft.
Confirming the menu applies it when speech preparation succeeds. Profiles are
The profile editor previews software voice, rate, pitch, and volume changes
using the same speech path as ordinary speech settings. Leaving the editor
restores the parent menu's voice; cancelling the menu restores the live voice.
**Use Voice Profile** loads the profile into the menu's primary speech draft
and previews supported software speech. Confirming the menu applies it when
speech preparation succeeds. Profiles are
also available through the Speech quick-settings category; those switches take
effect immediately for the session and use the ordinary save-settings command
to persist. Individual rate/pitch/volume adjustments leave the preset unchanged.
The Default choice remains available even when no named profiles are saved.
Removing a preset leaves the configured primary voice in place. Application
settings do not edit the global preset catalog.
+2 -1
View File
@@ -206,7 +206,8 @@ func (ui *internalUI) open_settings_context(settings config.Settings, path strin
ui.action = action
ui.changed = changed
ui.returnToParent = nil
ui.voice.Say(restored.Describe())
previewSpeech(restored)
ui.say(restored.Describe())
})
return
}
+15 -2
View File
@@ -71,7 +71,19 @@ func (ui *internalUI) manage_profiles(action string, parent *interaction.Session
parent.Close()
ui.session = child
ui.returnToParent = func() { restore(draft) }
ui.changed = editor.Refresh_session
ui.changed = func(session *interaction.Session) {
editor.Refresh_session(session)
if ui.previewSpeech == nil {
return
}
profile, err := editor.Read(session.Values())
if err != nil {
return // An incomplete edit must leave the working voice available.
}
if next, err := config.Apply_primary_voice(draft, profile); err == nil {
ui.previewSpeech(next.Presentation.Speech)
}
}
ui.action = func(name string, session *interaction.Session) {
if name != "save-profile" {
return
@@ -89,7 +101,8 @@ func (ui *internalUI) manage_profiles(action string, parent *interaction.Session
draft.VoiceProfiles = collection
restore(draft)
}
ui.voice.Say(child.Open())
ui.changed(child)
ui.say(child.Open())
}
// Profiles can select Speech Dispatcher even when the current primary is hardware.
if discovery.Driver != "speech-dispatcher" && ui.discoverChoices != nil {
+93
View File
@@ -238,3 +238,96 @@ func TestQuickVoiceProfileOfferedWithoutProfiles(t *testing.T) {
t.Fatal("saved voice without profiles not reported as Default", got)
}
}
func TestVoiceProfileEditorPreviewsAndRestoresParentDraft(t *testing.T) {
a, voice, _, prepared := preview_application(t)
a.open_settings()
receive_ui(t, a.ui)
if !a.ui.session.Focus_control("voice-profiles", "add") {
t.Fatal("missing Add Voice Profile")
}
a.ui.handle(interaction.Key{Name: "enter"})
a.ui.session.Focus_control(voiceprofiles.PageID, "rate")
a.ui.handle(interaction.Key{Name: "right"})
if got := last_parameters(t, voice); got.Rate != 10 {
t.Fatal("profile rate was not previewed", got)
}
// Module changes use the same silent preparation as ordinary settings.
control := a.ui.session.Values()[voiceprofiles.PageID+".module"]
control.Choices = append(control.Choices, interaction.Choice{ID: "fixture", Label: "fixture", Literal: true})
a.ui.session.Replace_choices(voiceprofiles.PageID, "module", control.Choices, "fixture")
a.ui.handle(interaction.Key{Name: "tab"})
if got := <-prepared; got.Module != "fixture" {
t.Fatal("profile module was not previewed", got)
}
finish_preview(t, a, voice)
if a.settings.live.Presentation.Speech.Rate != 0 || a.settings.live.Presentation.Speech.Module != "" {
t.Fatal("preview committed the profile")
}
a.ui.handle(interaction.Key{Name: "escape"})
if got := last_parameters(t, voice); got.Rate != 0 {
t.Fatal("cancel did not restore parent rate", got)
}
if got := <-prepared; got.Module != "" {
t.Fatal("cancel did not restore parent module", got)
}
finish_preview(t, a, voice)
}
func TestNewVoiceProfileCanBeConfirmedOnItsTabAndSelectedImmediately(t *testing.T) {
a, voice, path, _ := preview_application(t)
a.open_settings()
receive_ui(t, a.ui)
a.ui.session.Focus_control("voice-profiles", "add")
a.ui.handle(interaction.Key{Name: "enter"})
a.ui.handle(interaction.Key{Text: "Reading"})
a.ui.session.Focus_control(voiceprofiles.PageID, "rate")
a.ui.handle(interaction.Key{Name: "right"})
a.ui.session.Focus_control(voiceprofiles.PageID, "save")
a.ui.handle(interaction.Key{Name: "enter"})
if !a.ui.session.Focus_control("voice-profiles", "ok") {
t.Fatal("profile tab has no way to confirm its changes")
}
a.ui.handle(interaction.Key{Name: "enter"})
finish_persistence(t, a, false)
loaded, _, err := config.Load(path, nil)
if err != nil || len(loaded.VoiceProfiles.Profiles) != 1 || len(a.settings.live.VoiceProfiles.Profiles) != 1 {
t.Fatal("new profile missing from disk or runtime", loaded.VoiceProfiles, a.settings.live.VoiceProfiles, err)
}
for range 6 {
a.handle_command(command.NextQuickEntry)
}
a.handle_command(command.NextQuickValue)
finish_selection(t, a)
if got := a.settings.live.Presentation.Speech.Rate; got != 10 {
t.Fatal("new profile not immediately selectable", got, voice.messages)
}
}
func TestUseVoiceProfilePreviewsWithoutCommittingPrimary(t *testing.T) {
a, voice, path, prepared := preview_application(t)
draft := a.settings.live
draft.VoiceProfiles.Profiles = []voiceprofiles.Profile{{Name: "Reading", Driver: "speech-dispatcher", Module: "fixture", Rate: 30, Volume: 80}}
if err := config.Save(path, draft); err != nil {
t.Fatal(err)
}
a.open_settings()
receive_ui(t, a.ui)
a.ui.session.Focus_control("voice-profiles", "use")
a.ui.handle(interaction.Key{Name: "enter"})
if got := <-prepared; got.Module != "fixture" {
t.Fatal("Use Voice Profile did not preview the module", got)
}
finish_preview(t, a, voice)
if got := last_parameters(t, voice); got.Rate != 30 || got.Volume != 80 {
t.Fatal("Use Voice Profile did not preview its numbers", got)
}
if a.settings.live.Presentation.Speech.Module != "" {
t.Fatal("Use Voice Profile committed before parent confirmation")
}
a.ui.handle(interaction.Key{Name: "escape"})
if got := <-prepared; got.Module != "" {
t.Fatal("menu Cancel did not restore its original module", got)
}
finish_preview(t, a, voice)
}
@@ -429,7 +429,7 @@ msgid "Canada"
msgstr "Kanada"
#: internal/app/application_overrides.go:368
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:103 internal/preferences/settings.go:96
#: screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr "Abbrechen"
@@ -764,12 +764,12 @@ msgstr "Anwendungseinstellungen konnten nicht wiederhergestellt werden: {0}"
msgid "Could not save exceptions: {0}"
msgstr "Ausnahmen konnten nicht gespeichert werden: {0}"
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271
#: internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr "Einstellungen konnten nicht gespeichert werden: {0}"
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr "Stimmprofil konnte nicht gespeichert werden: {0}"
@@ -1684,7 +1684,7 @@ msgstr "Eidechse"
msgid "Llama"
msgstr "Lama"
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr "Stimmen werden geladen"
@@ -1982,7 +1982,7 @@ msgstr "Nicht im Fenstermodus"
msgid "Notifications"
msgstr "Benachrichtigungen"
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr "OK"
@@ -2974,7 +2974,7 @@ msgstr "Tennisball"
msgid "Test synthesizer"
msgstr "Sprachsynthesizer testen"
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr "Stimme wird getestet"
@@ -429,7 +429,7 @@ msgid "Canada"
msgstr "Canadá"
#: internal/app/application_overrides.go:368
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:103 internal/preferences/settings.go:96
#: screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr "Cancelar"
@@ -766,12 +766,12 @@ msgstr "No se pudo restaurar la configuración de la aplicación: {0}"
msgid "Could not save exceptions: {0}"
msgstr "No se pudieron guardar las excepciones: {0}"
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271
#: internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr "No se pudo guardar la configuración: {0}"
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr "No se pudo guardar el perfil de voz: {0}"
@@ -1687,7 +1687,7 @@ msgstr "Lagarto"
msgid "Llama"
msgstr "Llama"
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr "Cargando voces"
@@ -1993,7 +1993,7 @@ msgstr "No está en modo ventana"
msgid "Notifications"
msgstr "Notificaciones"
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr "Aceptar"
@@ -2983,7 +2983,7 @@ msgstr "Pelota de tenis"
msgid "Test synthesizer"
msgstr "Probar sintetizador"
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr "Probando la voz"
+6 -6
View File
@@ -417,7 +417,7 @@ msgstr ""
msgid "Canada"
msgstr ""
#: internal/app/application_overrides.go:368 internal/preferences/settings.go:96 screenreader-common/voiceprofiles/editor.go
#: internal/app/application_overrides.go:368 internal/preferences/settings.go:103 internal/preferences/settings.go:96 screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr ""
@@ -745,11 +745,11 @@ msgstr ""
msgid "Could not save exceptions: {0}"
msgstr ""
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270 internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271 internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr ""
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr ""
@@ -1649,7 +1649,7 @@ msgstr ""
msgid "Llama"
msgstr ""
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr ""
@@ -1941,7 +1941,7 @@ msgstr ""
msgid "Notifications"
msgstr ""
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr ""
@@ -2925,7 +2925,7 @@ msgstr ""
msgid "Test synthesizer"
msgstr ""
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr ""
@@ -430,7 +430,7 @@ msgid "Canada"
msgstr "Kanada"
#: internal/app/application_overrides.go:368
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:103 internal/preferences/settings.go:96
#: screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr "Anuluj"
@@ -766,12 +766,12 @@ msgstr "Nie można przywrócić ustawień aplikacji: {0}"
msgid "Could not save exceptions: {0}"
msgstr "Nie można zapisać wyjątków: {0}"
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271
#: internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr "Nie można zapisać ustawień: {0}"
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr "Nie można zapisać profilu głosu: {0}"
@@ -1686,7 +1686,7 @@ msgstr "jaszczurka"
msgid "Llama"
msgstr "lama"
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr "Wczytywanie głosów"
@@ -1987,7 +1987,7 @@ msgstr "Nie znajdujesz się w trybie okna."
msgid "Notifications"
msgstr "Powiadomienia"
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr "OK"
@@ -2977,7 +2977,7 @@ msgstr "Piłka tenisowa"
msgid "Test synthesizer"
msgstr "Testuj syntezator"
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr "Testowanie głosu"
@@ -428,7 +428,7 @@ msgid "Canada"
msgstr "Canadá"
#: internal/app/application_overrides.go:368
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:103 internal/preferences/settings.go:96
#: screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr "Cancelar"
@@ -764,12 +764,12 @@ msgstr "Não foi possível restaurar as configurações do aplicativo: {0}"
msgid "Could not save exceptions: {0}"
msgstr "Não foi possível salvar as exceções: {0}"
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271
#: internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr "Não foi possível salvar as configurações: {0}"
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr "Não foi possível salvar o perfil de voz: {0}"
@@ -1686,7 +1686,7 @@ msgstr "Lagartixa"
msgid "Llama"
msgstr "Lhama"
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr "Carregando vozes"
@@ -1990,7 +1990,7 @@ msgstr "Não no Modo de Janela"
msgid "Notifications"
msgstr "Notificações"
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr "OK"
@@ -2981,7 +2981,7 @@ msgstr "Bola de tênis"
msgid "Test synthesizer"
msgstr "Testar sintetizador"
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr "Testando a voz"
@@ -427,7 +427,7 @@ msgid "Canada"
msgstr "Канада"
#: internal/app/application_overrides.go:368
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:103 internal/preferences/settings.go:96
#: screenreader-common/voiceprofiles/editor.go
msgid "Cancel"
msgstr "Отмена"
@@ -763,12 +763,12 @@ msgstr "Не удалось восстановить настройки прил
msgid "Could not save exceptions: {0}"
msgstr "Не удалось сохранить исключения: {0}"
#: internal/app/fenrir_menu.go:264 internal/app/fenrir_menu.go:270
#: internal/app/fenrir_menu.go:265 internal/app/fenrir_menu.go:271
#: internal/app/runtime_settings.go:208 internal/app/runtime_settings.go:248
msgid "Could not save settings: {0}"
msgstr "Не удалось сохранить настройки: {0}"
#: internal/app/voice_profiles.go:81 internal/app/voice_profiles.go:86
#: internal/app/voice_profiles.go:93 internal/app/voice_profiles.go:98
msgid "Could not save voice profile: {0}"
msgstr "Не удалось сохранить голосовой профиль: {0}"
@@ -1682,7 +1682,7 @@ msgstr "Ящерица"
msgid "Llama"
msgstr "Лама"
#: internal/app/voice_profiles.go:100
#: internal/app/voice_profiles.go:113
msgid "Loading voices"
msgstr "Загрузка голосов"
@@ -1982,7 +1982,7 @@ msgstr "Не в режиме окна."
msgid "Notifications"
msgstr "Уведомления"
#: internal/preferences/settings.go:96
#: internal/preferences/settings.go:102 internal/preferences/settings.go:96
msgid "OK"
msgstr "ОК"
@@ -2973,7 +2973,7 @@ msgstr "Теннисный мяч"
msgid "Test synthesizer"
msgstr "Проверить синтезатор"
#: internal/app/fenrir_menu.go:229
#: internal/app/fenrir_menu.go:230
msgid "Testing voice"
msgstr "Проверка голоса"
+5 -1
View File
@@ -97,7 +97,11 @@ func new_session(settings config.Settings, order []string, title string, applica
form.Tabs = append(form.Tabs, tab)
}
if !application {
form.Tabs = append(form.Tabs, settings.VoiceProfiles.Tab())
profiles := settings.VoiceProfiles.Tab()
profiles.Controls = append(profiles.Controls,
interaction.Control{ID: "ok", Label: "OK", Kind: interaction.Button, Action: "save"},
interaction.Control{ID: "cancel", Label: "Cancel", Kind: interaction.Button, Action: "cancel"})
form.Tabs = append(form.Tabs, profiles)
}
return interaction.New_session(form)
}
+4 -1
View File
@@ -38,9 +38,12 @@ func TestSettingsFormCoversSchemaAndReturnsIsolatedDraft(t *testing.T) {
t.Fatal(got)
}
values := session.Values()
if len(values) != 65 {
if len(values) != 67 {
t.Fatal("missing settings or buttons", len(values))
}
if values["voice-profiles.ok"].Action != "save" || values["voice-profiles.cancel"].Action != "cancel" {
t.Fatal("profile changes cannot be confirmed or discarded on their tab")
}
unchanged, err := Settings(session, base)
if err != nil || !reflect.DeepEqual(unchanged, base) {
t.Fatal(unchanged, err)