Fixed missing include guard, C++ compat.

Automated flashing of TA/SG partitions to simplify usage.

Doc updates to reflect that change.
This commit is contained in:
Jade Mattsson
2024-03-23 21:22:47 +11:00
parent 16cc7d87f7
commit 1af3bae796
5 changed files with 40 additions and 23 deletions
+22 -4
View File
@@ -89,9 +89,27 @@ add_custom_command(OUTPUT ${PICOTTS_SG_BIN}
COMMAND cp ${PICOTTS_LANG_DIR}/${PICOTTS_SG_SRC} ${PICOTTS_SG_BIN_PATH})
add_custom_target(picotts_ta_bin_gen DEPENDS ${PICOTTS_TA_BIN_PATH})
add_custom_target(picotts_sg_bin_gen DEPENDS ${PICOTTS_SG_BIN_PATH})
target_add_binary_data(
${COMPONENT_LIB} ${PICOTTS_TA_BIN_PATH} BINARY DEPENDS picotts_ta_bin_gen)
target_add_binary_data(
${COMPONENT_LIB} ${PICOTTS_SG_BIN_PATH} BINARY DEPENDS picotts_sg_bin_gen)
set_property(DIRECTORY "${COMPONENT_DIR}" APPEND PROPERTY
ADDITIONAL_CLEAN_FILES ${PICOTTS_TA_BIN} ${PICOTTS_SG_BIN})
if(${CONFIG_PICOTTS_RESOURCE_MODE_PARTITION})
partition_table_get_partition_info(part_ta_size "--partition-name ${CONFIG_PICOTTS_TA_PARTITION}" "size")
partition_table_get_partition_info(part_ta_offs "--partition-name ${CONFIG_PICOTTS_TA_PARTITION}" "offset")
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")
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")
endif()
else()
target_add_binary_data(
${COMPONENT_LIB} ${PICOTTS_TA_BIN_PATH} BINARY DEPENDS picotts_ta_bin_gen)
target_add_binary_data(
${COMPONENT_LIB} ${PICOTTS_SG_BIN_PATH} BINARY DEPENDS picotts_sg_bin_gen)
endif()
+3 -11
View File
@@ -53,7 +53,7 @@ API documentation can be found in the [picotts.h](include/picotts.h) header file
The PicoTTS engine relies on two resource blobs, a Text Analysis (TA) resource and a Signal Generator (SG) resource. In upstream PicoTTS, these are loaded into RAM from files on disk. As RAM is a very precious resource on a microcontroller, this component has replaced the resource loading routines such that they can be accessed directly from memory-mapped flash instead. This reduces the RAM foot-print from 2.5MB down to 1.1MB.
There are two options on how to bundle the resource files onto flash. The default, and arguably the easiest, is to embed the resource files directly into the application binary. The one downside to this approach is that application size grows significantly, and may present an issue with firmware upgrades. You will definitely use a much larger application partition than usual. Alternatively, the resource files can be placed in dedicated flash partitions and accessed from there instead. These partitions have to be flashed independently from the application partition, but the advantage is that the language resources are no longer directly coupled to the application binary. Which approach is best will depend on the specific project circumstances.
There are two options on how to bundle the resource files onto flash. The default, and arguably the easiest, is to embed the resource files directly into the application binary. The one downside to this approach is that application size grows significantly, and may present an issue with firmware upgrades. You will definitely use a much larger application partition than usual. Alternatively, the resource files can be placed in dedicated flash partitions and accessed from there instead. The advantage with this approach is that the language resources are no longer directly coupled to the application binary. Which approach is best will depend on the specific project circumstances.
### Custom paritions for language resources
@@ -61,8 +61,8 @@ There are two options on how to bundle the resource files onto flash. The defaul
When this component is configured to load its language resources from partitions rather than having them directly embedded into the application binary itself, you will need to add partition entries to hold the Text Analysis (TA) and Signal Generator (SG) resources. Example entries for `partitions.csv`:
```
picotts_ta, 0x40, 0x0, , 640K,
picotts_sg, 0x40, 0x1, , 820K,
picotts_ta, data, undefined, , 640K,
picotts_sg, data, undefined, , 820K,
```
You are free to use any valid partition type and subtype. This component loads
@@ -70,14 +70,6 @@ purely by the partition name. The partition names may be changed via Kconfig if
The partition sizes may be shrunk to better match the language you're using. What's show here are the maximum partition sizes to fit any language bundle.
### Flashing language resources to partitions
When configured for loading language resources from partitions, the following commands can be used to flash them to the correct locations. These commands assume the partition names are "picotts\_ta" and "picotts\_sg", respectively.
```
parttool.py write_partition --partition-name picotts_ta --input build/esp-idf/picotts/picotts_ta.bin
parttool.py write_partition --partition-name picotts_sg --input build/esp-idf/picotts/picotts_sg.bin
```
## 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.
+1 -6
View File
@@ -19,11 +19,6 @@ idf.py build
idf.py flash
```
The partition table in this example also makes allowance for having the picotts language resource files stored in separate partitions, but if switching to that option you will additionally need to run:
```
parttool.py write_partition --partition-name picotts_ta --input build/esp-idf/picotts/picotts_ta.bin
parttool.py write_partition --partition-name picotts_sg --input build/esp-idf/picotts/picotts_sg.bin
```
The partition table in this example also makes allowance for having the picotts language resource files stored in separate partitions.
As usual, the console log can be accessed with `idf.py monitor`.
+2 -2
View File
@@ -1,6 +1,6 @@
version: "1.1.0"
version: "1.1.1"
description: "PicoTTS Text-to-Speech engine"
license: "Apache-2.0"
maintainers:
- J Mattsson <jmattsson@dius.com.au>
- Jade Mattsson <jmattsson@dius.com.au>
url: "https://github.com/DiUS/esp-picotts"
+12
View File
@@ -1,6 +1,13 @@
#ifndef PICOTTS_H
#define PICOTTS_H
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PICOTTS_SAMPLE_FREQ_HZ 16000
#define PICOTTS_SAMPLE_BITS 16
@@ -64,3 +71,8 @@ typedef void (*picotts_idle_notify_fn)(void);
* engine goes idle. Pass NULL to unregister a set callback function.
*/
void picotts_set_idle_notify(picotts_idle_notify_fn cb);
#ifdef __cplusplus
}
#endif
#endif