diff options
| author | Tursiae <git@tursiae.org> | 2025-02-11 00:23:35 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-02-11 00:23:35 +0000 |
| commit | 569ed6c0cc440572b37a06200b6706badcdf8e45 (patch) | |
| tree | ceda9ffeeab489f86bd71b8674f12d4cd4920623 /src/drivers/nvs.cpp | |
| parent | 29ad80d113970c5dcaed5a99c5478277a349b1a6 (diff) | |
| download | tangara-fw-569ed6c0cc440572b37a06200b6706badcdf8e45.tar.gz | |
TTS: Implement and wire up a TTS toggle in Display Settings (#251)
This change introduces the ability to enable or disable the spoken interface/TTS from the on-device settings, either via the UI or the Lua console. This closes out the implementation of issue #245.
The TTS setting is only visible in Display settings if voice samples are present in `/.tangara-tts/` on the SD card.
Playback of new TTS voice samples is inhibited when TTS is disabled. By default, the setting is enabled, as the device will only play back TTS voices if samples are present on disk.
If you need samples to test TTS on your device, feel free to grab the voice samples I have at https://codeberg.org/tursiae/tangara-tts-samples. There's about 80-85% coverage of the UI, with the remainder to be added soonish.
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/251
Co-authored-by: Tursiae <git@tursiae.org>
Co-committed-by: Tursiae <git@tursiae.org>
Diffstat (limited to 'src/drivers/nvs.cpp')
| -rw-r--r-- | src/drivers/nvs.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp index 04a93fd9..3250e556 100644 --- a/src/drivers/nvs.cpp +++ b/src/drivers/nvs.cpp @@ -29,6 +29,7 @@ static constexpr char kKeyBluetoothVolumes[] = "bt_vols"; static constexpr char kKeyBluetoothNames[] = "bt_names"; static constexpr char kKeyOutput[] = "out"; static constexpr char kKeyBrightness[] = "bright"; +static constexpr char kKeyTextToSpeech[] = "tts"; static constexpr char kKeyInterfaceTheme[] = "ui_theme"; static constexpr char kKeyAmpMaxVolume[] = "hp_vol_max"; static constexpr char kKeyAmpCurrentVolume[] = "hp_vol"; @@ -269,6 +270,7 @@ NvsStorage::NvsStorage(nvs_handle_t handle) lra_calibration_(kKeyLraCalibration), fast_charge_(kKeyFastCharge), brightness_(kKeyBrightness), + text_to_speech_(kKeyTextToSpeech), sensitivity_(kKeyScrollSensitivity), amp_max_vol_(kKeyAmpMaxVolume), amp_cur_vol_(kKeyAmpCurrentVolume), @@ -299,6 +301,7 @@ auto NvsStorage::Read() -> void { lra_calibration_.read(handle_); fast_charge_.read(handle_); brightness_.read(handle_); + text_to_speech_.read(handle_); sensitivity_.read(handle_); amp_max_vol_.read(handle_); amp_cur_vol_.read(handle_); @@ -324,6 +327,7 @@ auto NvsStorage::Write() -> bool { lra_calibration_.write(handle_); fast_charge_.write(handle_); brightness_.write(handle_); + text_to_speech_.write(handle_); sensitivity_.write(handle_); amp_max_vol_.write(handle_); amp_cur_vol_.write(handle_); @@ -532,6 +536,21 @@ auto NvsStorage::ScreenBrightness(uint_fast8_t val) -> void { brightness_.set(val); } +auto NvsStorage::UITextToSpeech() -> bool { + std::lock_guard<std::mutex> lock{mutex_}; + + // Default to enabling text-to-speech if not set; this may need to be + // revisited if we end up adding on-device speech generation, but in a world + // where speech samples need to be loaded onto the SD card, it makes sense to + // enable this by default, as it'll only work if speech samples are present. + return text_to_speech_.get().value_or(true); +} + +auto NvsStorage::UITextToSpeech(bool val) -> void { + std::lock_guard<std::mutex> lock{mutex_}; + text_to_speech_.set(val); +} + auto NvsStorage::InterfaceTheme() -> std::optional<std::string> { std::lock_guard<std::mutex> lock{mutex_}; return theme_.get(); |
