This repository was archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathspeech.py
More file actions
61 lines (47 loc) · 2.52 KB
/
Copy pathspeech.py
File metadata and controls
61 lines (47 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from common import utils
from common.telemetry import telemetry_py
from common.telemetry_events import TelemetryEvent
# The implementation is based off of https://microbit-micropython.readthedocs.io/en/v1.0.1/speech.html.
def translate(words):
"""
This function is not implemented in the simulator.
Given English words in the string ``words``, return a string containing
a best guess at the appropriate phonemes to pronounce. The output is
generated from this
`text to phoneme translation table <https://github.com/s-macke/SAM/wiki/Text-to-phoneme-translation-table>`_.
This function should be used to generate a first approximation of phonemes
that can be further hand-edited to improve accuracy, inflection and
emphasis.
"""
utils.print_for_unimplemented_functions(translate.__name__)
telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_SPEECH)
def pronounce(phonemes, pitch=64, speed=72, mouth=128, throat=128):
"""
This function is not implemented in the simulator.
Pronounce the phonemes in the string ``phonemes``. See below for details of
how to use phonemes to finely control the output of the speech synthesiser.
Override the optional pitch, speed, mouth and throat settings to change the
timbre (quality) of the voice.
"""
utils.print_for_unimplemented_functions(pronounce.__name__)
telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_SPEECH)
def say(words, pitch=64, speed=72, mouth=128, throat=128):
"""
This function is not implemented in the simulator.
Say the English words in the string ``words``. The result is semi-accurate
for English. Override the optional pitch, speed, mouth and throat
settings to change the timbre (quality) of the voice. This is a short-hand
equivalent of: ``speech.pronounce(speech.translate(words))``
"""
utils.print_for_unimplemented_functions(say.__name__)
telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_SPEECH)
def sing(phonemes, pitch=64, speed=72, mouth=128, throat=128):
"""
This function is not implemented in the simulator.
Sing the phonemes contained in the string ``phonemes``. Changing the pitch
and duration of the note is described below. Override the optional pitch,
speed, mouth and throat settings to change the timbre (quality) of the
voice.
"""
utils.print_for_unimplemented_functions(sing.__name__)
telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_SPEECH)