Exemplo n.º 1
0
def test_funcs():
    print('Testing basic functions')
    ph = speech.translate('hello world')
    assert ph == ' /HEHLOW WERLD'
    speech.pronounce('PIHTHUN', pitch=32, speed=60, mouth=100, throat=150)
    speech.say('hello')
    speech.sing('YEHSTERDEY5')
Exemplo n.º 2
0
def test_funcs():
    print('Testing basic functions')
    ph = speech.translate('hello world')
    assert ph == ' /HEHLOW WERLD'
    speech.pronounce('PIHTHUN', pitch=32, speed=60, mouth=100, throat=150)
    speech.say('hello')
    speech.sing('YEHSTERDEY5')
def beat_box(sound):
    if sound:
        display.show(Image.HEART)
        sleep(10)
        display.clear()
        speech.pronounce(sound)
    else:
        sleep(gap)
Exemplo n.º 4
0
def canta():
    enciende_farol()
    microbit.display.show(microbit.Image.MUSIC_QUAVERS)

    # The say method attempts to convert English into phonemes.
    speech.say("Puedo cantar!")
    microbit.sleep(1000)
    speech.say("Escuchame!")
    microbit.sleep(1000)

    # Clearing the throat requires the use of phonemes. Changing
    # the pitch and speed also helps create the right effect.
    speech.pronounce("AEAE/HAEMM", pitch=200, speed=100)  # Ahem
    microbit.sleep(1000)

    # Singing requires a phoneme with an annotated pitch for each syllable.
    solfa = [
        "#115DOWWWWWW",  # Doh
        "#103REYYYYYY",  # Re
        "#94MIYYYYYY",  # Mi
        "#88FAOAOAOAOR",  # Fa
        "#78SOHWWWWW",  # Soh
        "#70LAOAOAOAOR",  # La
        "#62TIYYYYYY",  # Ti
        "#58DOWWWWWW",  # Doh
    ]

    # Sing the scale ascending in pitch.
    song = ''.join(solfa)
    speech.sing(song, speed=100)
    # Reverse the list of syllables.
    solfa.reverse()
    song = ''.join(solfa)
    # Sing the scale descending in pitch.
    speech.sing(song, speed=100)

    microbit.display.show(microbit.Image.HAPPY)
    apaga_farol()
Exemplo n.º 5
0
import speech
from microbit import sleep

# The say method attempts to convert English into phonemes.
speech.say("I can sing!")
sleep(1000)
speech.say("Listen to me!")
sleep(1000)

# Clearing the throat requires the use of phonemes. Changing
# the pitch and speed also helps create the right effect.
speech.pronounce("AEAE/HAEMM", pitch=200, speed=100)  # Ahem
sleep(1000)

# Singing requires a phoneme with an annotated pitch for each syllable.
solfa = [
    "#58DOWWWWWW",  # Doh
    "#62REYYYYYY",  # Re
    "#70MIYYYYYY",  # Mi
    "#78FAOAOAOAOR",  # Fa
    "#88SOHWWWWW",  # Soh
    "#94LAOAOAOAOR",  # La
    "#103TIYYYYYY",  # Ti
    "#115DOWWWWWW",  # Doh
]

# Sing the scale descending in pitch.
song = ''.join(solfa)
speech.sing(song, speed=100)
# Reverse the list of syllables.
solfa.reverse()
Exemplo n.º 6
0
def pronounce(text=None):
    """ translate and pronounce """
    text = choose(sayings, text)

    speech.pronounce(speech.translate(text))
Exemplo n.º 7
0
        data = incoming.split("#")
    else:
        data[0] = "none"

    if gesture == "face up":
        pin1.write_analog(70)
        speech.say("zzz")
        display.scroll("NNN")
        sleep(3000)
    elif data[0] == 'flash':
        # If there's an incoming "flash" message display
        # the firefly flash animation after a random short
        # pause.
        sleep(random.randint(50, 350))
        display.show(flash, delay=100, wait=False)
        speech.pronounce("AE/H", pitch=200, speed=100)
        sleep(500)
    elif data[0] == 'name':
        # If there's an incoming "flash" message display
        # the firefly flash animation after a random short
        # pause.
        sleep(random.randint(50, 350))
        speech.say("Hello", pitch=200, speed=100)
        speech.say(data[1], pitch=200, speed=100)
        sleep(500)
    elif gesture == "shake":
        display.show(angry)
        speech.say("stop it")
    elif button_a.is_pressed():
        display.show(sad)
        pin1.write_analog(100)
Exemplo n.º 8
0
     radio.off()
     confirm()
 elif cmd == 'radio.reset':
     radio.reset()
     confirm()
 elif cmd == 'radio.send_bytes':
     radio.send_bytes(to_bytes(params[1]))
     confirm()
 elif cmd == 'radio.receive_bytes':
     msg = radio.receive_bytes()
     print(from_bytes(msg) if msg else '')
 elif cmd == 'speech.translate':
     print(escape(speech.translate(unescape(params[1]))))
 elif cmd == 'speech.pronounce':
     speech.pronounce(unescape(params[1]), \
             pitch=int(params[2]), speed=int(params[3]), \
             mouth=int(params[4]), throat=int(params[5]))
     confirm()
 elif cmd == 'speech.say':
     gc.collect()
     speech.say(unescape(params[1]), \
             pitch=int(params[2]), speed=int(params[3]), \
             mouth=int(params[4]), throat=int(params[5]))
     confirm()
 elif cmd == 'speech.sing':
     speech.sing(unescape(params[1]), \
             pitch=int(params[2]), speed=int(params[3]), \
             mouth=int(params[4]), throat=int(params[5]))
     confirm()
 elif cmd == 'speaker.on':
     speaker.on()
Exemplo n.º 9
0
from microbit import *
#from microbit import speech
#from microbit import random
import speech
import random

location = random.choice(["einem Kiesel", "einer Wiese", "dem Zwiesel"])
action = random.choice(["sass", "stand", "lag", "schlief"])
subj = (["Wiesel"])
prop = random.choice(["Bachgeriesel", "Schneegriesel", "einer Pfuetze Diesel"])
clue = random.choice(["das Mondkalb", "der Nachtalb"])
attitude = random.choice(["um des Reimes Willen", "um einfach mal zu chillen"])

poem = [
    "Das aesthetische Wiesel frei nach Christian Morgenstern",
    "Ein {}".format(subj), "{} auf".format(action), "inmitten {}".format(prop),
    "Wisst ihr, weshalb?", "{} verriet es mir im Stillen:".format(clue),
    "Das raffinierte Tier tats {}".format(attitude)
]
for line in poem:
    speech.say(line, speed=120, pitch=100, throat=100, mouth=200)
    speech.pronounce(line, pitch=100, speed=48, mouth=128, throut=128)
    sleep(500)
Exemplo n.º 10
0
import speech
from microbit import sleep

# The say method attempts to convert English into phonemes.
speech.say("I can sing!")
sleep(1000)
speech.say("Listen to me!")
sleep(1000)

# Clearing the throat requires the use of phonemes. Changing
# the pitch and speed also helps create the right effect.
speech.pronounce("AEAE/HAEMM", pitch=200, speed=100)  # Ahem
sleep(1000)

# Singing requires a phoneme with an annotated pitch for each syllable.
solfa = [
    "#115DOWWWWWW",   # Doh
    "#103REYYYYYY",   # Re
    "#94MIYYYYYY",    # Mi
    "#88FAOAOAOAOR",  # Fa
    "#78SOHWWWWW",    # Soh
    "#70LAOAOAOAOR",  # La
    "#62TIYYYYYY",    # Ti
    "#58DOWWWWWW",    # Doh
]

# Sing the scale ascending in pitch.
song = ''.join(solfa)
speech.sing(song, speed=100)
# Reverse the list of syllables.
solfa.reverse()
Exemplo n.º 11
0
def show_and_pronounce(word):
    string = speech.translate(word)
    speech.pronounce(string,speed=120, pitch=100, throat=100, mouth=200)
    display.scroll(word)    
Exemplo n.º 12
0
import speech

speech.say("Hello world")
speech.say("I am a Daleak - Exterminate!",
           speed=120,
           pitch=100,
           throat=100,
           mouth=200)
speech.pronounce("/HEH5EH4EH3EH2EH2EH3EH4EH5EHLP.")
Exemplo n.º 13
0
import math

display.show(Image.HAPPY)
while True:
    while button_a.is_pressed():
        pin0.set_analog_period_microseconds(256)
        pin2value = pin2.read_analog()
        pin1value = pin1.read_analog()
        while button_b.is_pressed():
            duration = pin2.read_analog()
            step = pin1.read_analog()
            for i in range(0, 1023, 1):
                for j in range(0, duration, step):
                    pin0.write_analog(i)
            for i in range(1023, 0, -1):
                for j in range(0, duration, step):
                    pin0.write_analog(i)

        music.pitch(pin2value, pin1value)
        sleep(pin1value)
    while button_b.is_pressed():
        pin2value = pin2.read_analog()
        pin2value = math.floor(pin2value / 4)
        pin1value = pin1.read_analog()
        pin1value = math.floor(pin1value / 4)
        string = speech.translate("Rock on!")
        speech.pronounce(string,
                         speed=120,
                         pitch=pin2value,
                         throat=100,
                         mouth=pin1value)
Exemplo n.º 14
0
import speech
import time

from microbit import *

last_gesture = accelerometer.current_gesture()

while True:
    gesture = accelerometer.current_gesture()
    if last_gesture != gesture:
        if gesture == "left":
            speech.pronounce("CHUXAH", speed=150, mouth=70)
        elif gesture == "right":
            speech.pronounce("IHAA", speed=150, mouth=90)
        elif gesture == "up":
            speech.pronounce("/HOW4", speed=150)
        elif gesture == "down":
            speech.pronounce("CHEY4", speed=150)
        last_gesture = gesture
Exemplo n.º 15
0
import speech

speech.pronounce("SAANLAENTAAN", pitch=40, speed=100, mouth=128, throat=128)

# speech.pronounce("/HEH5EH4EH3EH2EH2EH3EH4EH5EHLP.")
Exemplo n.º 16
0
# The speech module is not in the microbit library.
# We have to import it separately
import speech
from microbit import *

# Use say in order to make your micro:bit say things.
'''
speech.say('Hackonnect is the best.')
sleep(1000)
speech.say('I agree.')
sleep(1000)
'''

# Of course, in order to make sounds that cannot be described by words, we need another method.
# For this, we can use phenomes with the pronounce() function.
'''
speech.pronounce('/HEH5EH4EH3EH2EH2EH3EH4EH5EHLP')

# You can also use translate in order to translate English into Phenomes
speech.pronounce(translate('Aww, I\'m so sorry!'))
sleep(1000)

# We can also use different pitches with sing.
sing('#115DOWWWW')
'''

# Of course, this is a really hard way to play music.
# We can use the music module to play music.
from music import *

# Here is how musical notes work with the microbit: