Skip to content

Commit e86bc10

Browse files
committed
codal_port/modspeech: Make default speech mode externally configurable.
By defining MICROPY_PY_SPEECH_DEFAULT_MODE in mpconfigport.h. Signed-off-by: Damien George <damien@micropython.org>
1 parent 8dfe395 commit e86bc10

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/codal_port/modspeech.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
#include "sam/reciter.h"
3838
#include "sam/sam.h"
3939

40+
// The default `mode` for say/pronounce/sing can be configured externally.
41+
// The allowed values are:
42+
// - 0 = traditional micro:bit v1, 15625Hz (not supported with USE_DEDICATED_AUDIO_CHANNEL)
43+
// - 1 = standard sampling fidelity, 19000Hz
44+
// - 2 = standard sampling fidelity, 19000Hz, with sample smoothing
45+
// - 3 = higher sampling fidelity, 38000Hz
46+
// - 4 = higher sampling fidelity, 38000Hz, with sample smoothing
47+
#ifndef MICROPY_PY_SPEECH_DEFAULT_MODE
48+
#define MICROPY_PY_SPEECH_DEFAULT_MODE (1)
49+
#endif
50+
4051
// If disabled, pipe speech through audio module output.
4152
// If enabled, use a dedicated audio mixer channer with a double buffer.
4253
#define USE_DEDICATED_AUDIO_CHANNEL (1)
@@ -386,7 +397,7 @@ STATIC mp_obj_t articulate(mp_obj_t phonemes, mp_uint_t n_args, const mp_obj_t *
386397
{ MP_QSTR_mouth, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = DEFAULT_MOUTH} },
387398
{ MP_QSTR_throat, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = DEFAULT_THROAT} },
388399
{ MP_QSTR_debug, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
389-
{ MP_QSTR_mode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
400+
{ MP_QSTR_mode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MICROPY_PY_SPEECH_DEFAULT_MODE} },
390401
{ MP_QSTR_volume, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 4} },
391402
{ MP_QSTR_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&microbit_pin_default_audio_obj)} },
392403
};

0 commit comments

Comments
 (0)