From f7d2529b93c5a37f4e3faa48f65d4e5392bc7ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=27=C3=A9lectron=20rare?= <108685187+electron-rare@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:08:08 +0100 Subject: [PATCH] chore(tts): stage local changes Co-Authored-By: Claude Opus 4.6 --- .espressif/esp-idf | 1 + .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++ CMakeLists.txt | 20 ++++++++++++----- LICENSE.md | 3 +++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++ esp_picorsrc.c | 14 ++++++------ esp_picotts.c | 13 +++++++---- 7 files changed, 113 insertions(+), 17 deletions(-) create mode 160000 .espressif/esp-idf create mode 100644 .github/workflows/ci.yml create mode 100644 LICENSE.md diff --git a/.espressif/esp-idf b/.espressif/esp-idf new file mode 160000 index 0000000..97d9585 --- /dev/null +++ b/.espressif/esp-idf @@ -0,0 +1 @@ +Subproject commit 97d95853572ab74f4769597496af9d5fe8b6bdea diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..618ed80 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [main, master] + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cmake: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Configure + run: cmake -S . -B build + - name: Build + run: cmake --build build --config Release --parallel + - name: CTest smoke + run: | + if [ -f build/CTestTestfile.cmake ]; then + ctest --test-dir build --output-on-failure + else + echo "No CTest tests discovered" + fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 750c9e0..5454287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ set_source_files_properties( # PicoTTS attempts to use exp() trickery which relies on a particular floating # point representation format, which seemingly does not hold on Xtensa. As -# a workaround, we rename the picoos_quick_exp functin and provide our own +# a workaround, we rename the picoos_quick_exp function and provide our own # wrapper back to standard math.h exp() instead. set_source_files_properties( "pico/lib/picoos.c" @@ -84,13 +84,21 @@ elseif(CONFIG_PICOTTS_LANGUAGE_IT_IT) set(PICOTTS_SG_SRC "it-IT_cm0_sg.bin") endif() -add_custom_command(OUTPUT ${PICOTTS_TA_BIN} COMMAND ${CMAKE_COMMAND} -E copy ${PICOTTS_LANG_DIR}/${PICOTTS_TA_SRC} ${PICOTTS_TA_BIN_PATH}) -add_custom_command(OUTPUT ${PICOTTS_SG_BIN} COMMAND ${CMAKE_COMMAND} -E copy ${PICOTTS_LANG_DIR}/${PICOTTS_SG_SRC} ${PICOTTS_SG_BIN_PATH}) +add_custom_command( + OUTPUT ${PICOTTS_TA_BIN_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${PICOTTS_LANG_DIR}/${PICOTTS_TA_SRC} ${PICOTTS_TA_BIN_PATH} + VERBATIM +) +add_custom_command( + OUTPUT ${PICOTTS_SG_BIN_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${PICOTTS_LANG_DIR}/${PICOTTS_SG_SRC} ${PICOTTS_SG_BIN_PATH} + VERBATIM +) add_custom_target(picotts_ta_bin_gen DEPENDS ${PICOTTS_TA_BIN_PATH}) add_custom_target(picotts_sg_bin_gen DEPENDS ${PICOTTS_SG_BIN_PATH}) set_property(DIRECTORY "${COMPONENT_DIR}" APPEND PROPERTY - ADDITIONAL_CLEAN_FILES ${PICOTTS_TA_BIN} ${PICOTTS_SG_BIN}) + ADDITIONAL_CLEAN_FILES ${PICOTTS_TA_BIN_PATH} ${PICOTTS_SG_BIN_PATH}) if(${CONFIG_PICOTTS_RESOURCE_MODE_PARTITION}) partition_table_get_partition_info(part_ta_size "--partition-name ${CONFIG_PICOTTS_TA_PARTITION}" "size") @@ -98,14 +106,14 @@ if(${CONFIG_PICOTTS_RESOURCE_MODE_PARTITION}) if ("${part_ta_size}" AND "${part_ta_offs}") esptool_py_flash_to_partition(flash "${CONFIG_PICOTTS_TA_PARTITION}" "${PICOTTS_TA_BIN_PATH}") else() - set(message "Failed to find ${CONFIG_PICOTTS_TA_PARTITION} in partition table") + message(FATAL_ERROR "Failed to find ${CONFIG_PICOTTS_TA_PARTITION} in partition table") endif() partition_table_get_partition_info(part_sg_size "--partition-name ${CONFIG_PICOTTS_SG_PARTITION}" "size") partition_table_get_partition_info(part_sg_offs "--partition-name ${CONFIG_PICOTTS_SG_PARTITION}" "offset") if ("${part_sg_size}" AND "${part_sg_offs}") esptool_py_flash_to_partition(flash "${CONFIG_PICOTTS_SG_PARTITION}" "${PICOTTS_SG_BIN_PATH}") else() - set(message "Failed to find ${CONFIG_PICOTTS_SG_PARTITION} in partition table") + message(FATAL_ERROR "Failed to find ${CONFIG_PICOTTS_SG_PARTITION} in partition table") endif() add_dependencies(${COMPONENT_LIB} picotts_ta_bin_gen picotts_sg_bin_gen) else() diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..98b40ba --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,3 @@ +This Source Code Form is subject to the terms of the Mozilla Public License, +v. 2.0. If a copy of the MPL was not distributed with this file, You can +obtain one at https://mozilla.org/MPL/2.0/. diff --git a/README.md b/README.md index 9837b28..649d66f 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,51 @@ The partition sizes may be shrunk to better match the language you're using. Wha ## Examples The [boot\_greeting](examples/boot_greeting/README.md) example is written for ESP-BOX and uses this component to issue a greeting upon boot. + + + + + + + + + + + + + + + + + + + + + + + + +## Audit & Execution Plan (2026-03-10) + +### Snapshot +- Priority: `P2` +- Tech profile: `cpp/cmake` +- Workflows: `yes` +- Tests: `yes` +- Debt markers: `0` +- Source files: `71` + +### Corrections Prioritaires +- [ ] Ajouter smoke build CMake +- [ ] Ajouter/fiabiliser les commandes de vérification automatiques. +- [ ] Clore les points bloquants avant optimisation avancée. + +### Optimisation +- [ ] Identifier le hotspot principal et mesurer avant/après. +- [ ] Réduire la complexité des modules les plus touchés. + +### Mémoire chantier +- Control plane: `/Users/electron/.codex/memories/electron_rare_chantier` +- Repo card: `/Users/electron/.codex/memories/electron_rare_chantier/REPOS/esp-picotts.md` + + diff --git a/esp_picorsrc.c b/esp_picorsrc.c index d9d85b6..b8e3d1a 100644 --- a/esp_picorsrc.c +++ b/esp_picorsrc.c @@ -20,18 +20,18 @@ static uint16_t esp_pico_load_pi_u16(const char *raw, unsigned offs) { - uint16_t a = raw[offs]; - uint16_t b = raw[offs+1]; + uint16_t a = (uint8_t)raw[offs]; + uint16_t b = (uint8_t)raw[offs+1]; return (b << 8 | a); } static uint32_t esp_pico_load_pi_u32(const char *raw, unsigned offs) { - uint32_t a = raw[offs]; - uint32_t b = raw[offs+1]; - uint32_t c = raw[offs+2]; - uint32_t d = raw[offs+3]; - return (d << 24 || c << 16 | b << 8 | a); + uint32_t a = (uint8_t)raw[offs]; + uint32_t b = (uint8_t)raw[offs+1]; + uint32_t c = (uint8_t)raw[offs+2]; + uint32_t d = (uint8_t)raw[offs+3]; + return (d << 24) | (c << 16) | (b << 8) | a; } diff --git a/esp_picotts.c b/esp_picotts.c index e826cbd..a51bb69 100644 --- a/esp_picotts.c +++ b/esp_picotts.c @@ -188,7 +188,10 @@ static void esp_pico_run(void *) status = pico_getData(picoEngine, outbuf, sizeof(outbuf), &bytes, &type); if (bytes > 0) - outputCb(outbuf, bytes/2); + { + if (outputCb) + outputCb(outbuf, bytes / 2); + } } while (status == PICO_STEP_BUSY); if (status != PICO_STEP_IDLE) { @@ -205,11 +208,10 @@ static void esp_pico_run(void *) } } ESP_LOGI(tag, "Exiting task"); - xSemaphoreGive(exitLock); - vTaskDelete(NULL); - if (error && errorCb) errorCb(); + xSemaphoreGive(exitLock); + vTaskDelete(NULL); } @@ -357,6 +359,9 @@ bool picotts_init(unsigned prio, picotts_output_fn cb, int core) void picotts_add(const char *text, unsigned len) { + if (!textQ || !text || !len) + return; + while(len--) xQueueSendToBack(textQ, text++, portMAX_DELAY); }