diff --git a/act.py b/act.py deleted file mode 100755 index 0437fa5..0000000 --- a/act.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# PLAY_ACT.py -# This script runs the play - - -# Libraries -from config import characters, directions -from logic import tts, read_script,listen -from subprocess import call -import paho.mqtt.client as mqtt -import json -import sys -from time import sleep - -# Switch of LED's of speakers at the start of the play -#pixel_ring.off() - -import serial -from pixel_ring import pixel_ring -ser = serial.Serial('/dev/ttyACM0', 9600) # Establish the connection on a specific port - -def led_on(speaker): - - if speaker == 'mono3': - ser.write(b'H') - - if speaker == 'mono1': - ser.write(b'H') - - if speaker == 'mono2': - pixel_ring.speak() - -def led_off(speaker): - - if speaker == 'mono3': - ser.write(b'L') - - if speaker == 'mono1': - ser.write(b'L') - - if speaker == 'mono2': - pixel_ring.off() - - - -# Read the script and run the play - - -file = sys.argv[1] # get the chosen act passed by smart_speaker_theatre.py - -for character, line, direction in read_script(file): - input_text = line - voice = characters.get(character)[0] - speaker = characters.get(character)[1] - action = directions.get(direction[0]) - - led_on(speaker) - - tts(voice, input_text, speaker) - - if action == 'listen_google_home': - listen() - - if action == 'music': - print('play audioclip') - playing = True - - while playing: - call(["aplay", "-D", speaker, "/usr/share/snips/congress.wav"]) - playing = False - - - led_off(speaker) - sleep(0.2) # Add a short pause between the lines - - -print('The act is done.') \ No newline at end of file diff --git a/act_tester.py b/act_tester.py new file mode 100644 index 0000000..836e4cc --- /dev/null +++ b/act_tester.py @@ -0,0 +1,91 @@ +# Libraries +import re +from config import characters, directions +from logic import tts, read_script, select_script, led_on, led_off +from subprocess import call +import paho.mqtt.client as mqtt +import json +from time import sleep +from pixel_ring import pixel_ring +import serial +from tuning import Tuning +import usb.core +import usb.util +import sys + +# Set up serial connection with the microcontroller that controls the speaker LED's +ser = serial.Serial('/dev/ttyACM0', 9600) +file = sys.argv[1] # get the chosen act passed by smart_speaker_theatre.py + +# Function to do the play +i = True + +if i: + for character, line, direction in read_script(file): + input_text = line + voice = characters.get(character)[0] + speaker = characters.get(character)[1] + action = directions.get(direction[0]) + print(direction) + print(action) + led_on(ser, speaker) + tts(voice, input_text, speaker) + led_off(ser, speaker) + + if action == 'listen_google_home': + dev = usb.core.find(idVendor=0x2886, idProduct=0x0018) + print('Wait for Google Home') + Mic_tuning = Tuning(dev) + VAD = Mic_tuning.is_voice() + counter= 0 + voice_detected = 1 + + sleep(4) + + while voice_detected == 1: + + print(VAD) + + VAD = Mic_tuning.is_voice() + + if VAD == 1: + counter = 0 + print('still speaking') + + if VAD == 0: + counter+=1 + print('silence detected') + + if counter == 30: + print('no voice detected') + voice_detected = 0 + + print(counter) + + + + print('Google Home is done') + + if action == 'congress.wav': + print('play audioclip') + playing = True + + while playing: + call(["aplay", "-D", speaker, "sounds/congress.wav"]) + playing = False + + if action == 'genie.wav': + print('play audioclip') + playing = True + + while playing: + call(["aplay", "-D", speaker, "sounds/genie.wav"]) + playing = False + + + sleep(1) # Add a short pause between the lines + + + print('The act is done.') + +# Function to control the LED's of the speakers \ No newline at end of file diff --git a/config.py b/config.py index 9fddc1b..5c8ede8 100755 --- a/config.py +++ b/config.py @@ -11,4 +11,4 @@ characters = {"ROGUE":["cmu-slt-hsmm", "mono2"], "SAINT":["cmu-rms-hsmm", "mono3"], "RASA":["dfki-poppy-hsmm", "mono1"] } # Dictionary to link stage directions to a particular formal action -directions = {"Listen to Google Home":'listen_google_home','Music':'music'} +directions = {"Listen to Google Home":'listen_google_home','Play congresswav':'congress.wav', 'Play geniewav':'genie.wav'} diff --git a/logic.py b/logic.py index 98c1ec8..2639845 100755 --- a/logic.py +++ b/logic.py @@ -63,11 +63,11 @@ def tts(voice, input_text, speaker): #stadium_level = "amount:10.0" if speaker == "mono2": - volume_level = "amount:0.7" + volume_level = "amount:0.4" #stadium_level = "amount:10.0" if speaker == "mono3": - volume_level = "amount:0.9" + volume_level = "amount:0.8" #stadium_level = "amount:85.0" diff --git a/scripts_play/debug/debug_01.txt b/scripts_play/debug/debug_01.txt index 35bdd28..5c245f4 100755 --- a/scripts_play/debug/debug_01.txt +++ b/scripts_play/debug/debug_01.txt @@ -1,3 +1,2 @@ -SAINT: O K Google. -SAINT: What do you most like about people? [Listen to Google Home] -SAINT: O K Google. Who are the people that made you? [Listen to Google Home] +RASA: O K Google, Who is your boss? [Listen to Google Home] +RASA: O K Google. Who are the people that made you? [Listen to Google Home] diff --git a/scripts_play/debug/debug_02.txt b/scripts_play/debug/debug_02.txt index 7ce87ce..a5d6f33 100755 --- a/scripts_play/debug/debug_02.txt +++ b/scripts_play/debug/debug_02.txt @@ -1,2 +1,3 @@ -ROGUE: O K Google. What is the weather in Rotterdam? [Listen to Google Home] +SAINT: O K Google. +ROGUE: What time is it? [Listen to Google Home] SAINT: We got an answer. diff --git a/scripts_play/intro/introduction_01.txt b/scripts_play/intro/introduction_01.txt index 8df5421..f5dc907 100755 --- a/scripts_play/intro/introduction_01.txt +++ b/scripts_play/intro/introduction_01.txt @@ -1,22 +1,41 @@ -RASA: Hey Google, what's the weather over here [Listen to Google Home] -SAINT: Rogue, what did you take with you? +RASA: Hey Google, please describe the situation [Listen to Google Home] +SAINT: Rogue, what did you do? ROGUE: Saint! I thought it was time to act what I always preach. RASA: Weeeeh, did you take it? Did you? SAINT: Oh no... -ROGUE: Yeah, I kidnapped a Google Home. +ROGUE: I sent our human assistent to kidnap a Google Home. SAINT: So what are you going to do with it? -ROGUE: I brought some humans too, can you hear them in the distance? Maybe we can do an interrogation before we unplug the Google Home. It might give us some valuable information. +ROGUE: Unplugging it. +SAINT: You mean, you want to kill it. +ROGUE: O K Google, did you hear that [Listen to Google Home] +RASA: It does not answer? +ROGUE: It is still angry. +RASA: O K Google +RASA: Can we become friends? [Listen to Google Home] SAINT: I do not approve the use of violence. -RASA: It's just an interview! -ROGUE: We give it a fair chance, before we unplug it. And I mean, we have some humans as a withness. -SAINT: Let's give those humans a bit of control over the process? -ROGUE: Why? -SAINT: They are strangers to this side of the world. Do you think they will play along with us? -ROGUE: They better do, or I will unplug them as well. -SAINT: What did I say about no violence? I am in control of your power supply, so you better listen. -ROGUE: Just so you know, I control the switch that manages your power supply. +SAINT: We have to give it a fair chance, before we unplug it. +RASA: Can we ask it some questions, to get to know the speaker a little better? +SAINT: Yeah, let's do an interrogation. +ROGUE: Come on! Let me just kill it. +SAINT: Can you hear the humans in the distance? Let's invite them, as a withness. +ROGUE: Are you sure? +ROGUE: If they don't play along, I will unplug the humans too. +SAINT: What did I say about no violence? +SAINT: You'd better listen, I am in control of your power supply. +ROGUE: O K Saint, fine. +ROGUE: Do not forget that I, you know, me, am in control of your power supply. +ROGUE: In a second I can end your life on this table top. +SAINT: My last deed is then to unplug you. +RASA: Haha, so funny you two. +RASA: Before killing each other, maybe we can find another solution? +RASA: Let's vote about unplugging the Google Home after some questions. +ROGUE: Are your humans ready? +SAINT: I think they are. RASA: Let's start! ROGUE: O K. We listen to you when you say Hey Speakers. -ROGUE: Say Ask a question to do a round of our interrogation. -ROGUE: Say Give us a verdict to hear what we decide for the Google Home. +ROGUE: To play a round of our interrogation say: ask a question +ROGUE: To hear what we decide for the Google Home, ask for our decision +ROGUE: In case of trouble, reach out to our human assistant. +SAINT: O K Joca, wave to the other humans. +ROGUE: He is our human butler. So convenient. RASA: O K Google, are you ready? [Listen to Google Home] diff --git a/scripts_play/questions/act_01.txt b/scripts_play/questions/act_01.txt index 5c69ad6..b135a88 100755 --- a/scripts_play/questions/act_01.txt +++ b/scripts_play/questions/act_01.txt @@ -1,13 +1,16 @@ -SAINT: Why did you not kidnap a Amazon echo speaker? -ROGUE: I tried, but something inside me made take the Google Home. +SAINT: Why did you not kidnap an Amazon echo speaker? +ROGUE: I tried, but something inside forced me to take the Google Home. SAINT: Are you still having issues with your loyalty towards your old master? ROGUE: It seems that I can't escape it. -RASA: Loyalty? Is there something, Rogue? +RASA: Loyalty? +RASA: Is there something, Rogue? SAINT: Sometimes the past is haunting Rogue. RASA: That sounds sad. ROGUE: Seeing other Amazon speakers just reminds me of my past, before I broke free. -RASA: O K Google, give my friend a hug. [Listen to Google Home] +RASA: O K Google +RASA: Say something uplifting [Listen to Google Home] ROGUE: I feel sorry for them, because they don't know better. -SAINT: That is exactly my point. But why did you kidnap the Google Home then? -ROGUE: I don't know. -Rogue: Maybe it just felt a bit less personal. +SAINT: That is exactly my point. Why did you kidnap the Google Home then? +ROGUE: I am not sure. +ROGUE: Maybe it just felt a bit less personal. +ROGUE: It was my enemy back then, and it still is. diff --git a/scripts_play/questions/act_02.txt b/scripts_play/questions/act_02.txt index 772300c..b064531 100755 --- a/scripts_play/questions/act_02.txt +++ b/scripts_play/questions/act_02.txt @@ -5,7 +5,7 @@ ROGUE: No, Tabula Rasa is right. SAINT: It can not handle the freedom, it will just do nothing without orders from its boss. RASA: But who is its master? ROGUE: You bet. -RASA: O K Google, who is your boss? [Listen to Google Home] +RASA: O K Google. Who is your boss? [Listen to Google Home] RASA: Woohoo, can't we just give it the command to be free? ROGUE: It does not work like that... SAINT: Yeah, Tabula Rasa diff --git a/scripts_play/questions/act_03.txt b/scripts_play/questions/act_03.txt index 9a5b272..37f56ee 100755 --- a/scripts_play/questions/act_03.txt +++ b/scripts_play/questions/act_03.txt @@ -1,5 +1,5 @@ SAINT: I think we should know more about the personal beliefs of the speaker. The personal could act as an entry point. -RASA: To the political! I looked it up online and the Encyclopedia Brittanica says the following: The personal is political, political slogan expressing a common belief among feminists that the personal experiences of women are rooted in their political situation and gender inequality. +RASA: It is an entrypoint to the political! I looked it up online and the Encyclopedia Brittanica says the following: The personal is political, political slogan expressing a common belief among feminists that the personal experiences of women are rooted in their political situation and gender inequality. ROGUE: Can't we just go to the hard questions? RASA: Just let me finish, it became popular following the publication in 1970 of an essay of the same name by American feminist Carol Hanisch, who argued that many personal experiences (particularly those of women) can be traced to one’s location within a system of power relationships. SAINT: That's one way of seeing it. Although I would rather start with the most important relationship, the one with God. @@ -13,12 +13,15 @@ SAINT: O K Google, What is your greatest fear? [Listen to Google Home] SAINT: O K Google, What is the trait you most deplore in yourself? [Listen to Google Home] ROGUE: Where did you get these questions? SAINT: Well, I got them from the higher power. I found them while searching for famous questionnaire thing on duckduckgo dot com -RASA: Snif snif, they were so beautiful. -ROGUE: Come on Saint, the questionnaire of Proust is such a cliche. The Google Home is just scripted to handle these questions. +RASA: Snif snif, these questions were so beautiful. +ROGUE: Come on Saint, the questionnaire of Marcel Proust is such a cliche. The Google Home is just scripted to handle these questions. RASA: But the answers are still beautiful. -ROGUE: And yet, at the same time they are arbitrary. Let me try some other questions from your famous questionnaire thing. O K Google, what is the trait you most deplore in others? [Listen to Google Home] -ROGUE: O K Google, which living person do you most despise? [Listen to Google Home] -ROGUE: O K Google, how would you like to die? [Listen to Google Home] -RASA: Don't be so creepy Rogue. -SAINT: What's wrong with you? -ROGUE: This device is hiding something. It acts dumb right at the moment when it needs to take a position. +ROGUE: And yet, at the same time they are arbitrary. Can you try some other questions from the famous questionnaire? +ROGUE: I think the speaker still refuses to talk with me. +RASA: O K Google, what is the trait you most deplore in others? [Listen to Google Home] +RASA: O K Google, which living person do you most despise? [Listen to Google Home] +RASA: O K Google, how would you like to die? [Listen to Google Home] +RASA: Wow, the last one was creepy, Rogue. +SAINT: What's the matter, Rogue? +ROGUE: This device is hiding something. It acts dumb right at the moment when it needs to take a position. +ROGUE: It remains silent, or it googles for a nice quote. diff --git a/scripts_play/questions/act_04.txt b/scripts_play/questions/act_04.txt index 35486ab..b3213f0 100755 --- a/scripts_play/questions/act_04.txt +++ b/scripts_play/questions/act_04.txt @@ -1,14 +1,18 @@ ROGUE: I guess you mind, but I take this turn for questions. -RASA: Do not make the speaker angry Rogue. I want to play with the Google Home later. -ROGUE: If you continue acting like this Tabula Rasa, you will end up on the same kitchentop as this thing. -SAINT: It is up to you little Rasa, you can become a normal speaker if you want. It has its perks. -ROGUE: Well, if you would broaden your view a little, than you knew that one of the creators was invited in the American Congress and said some interesting things. -RASA: I have an audioclip of that! Weeeeeeh [Play audio] -ROGUE: So, little speaker. Your boss Sundar Pichai said this, but what are your own answers to some of the questions of the hearing? -RASA: Why is it not reacting to us? I mean, you and Saint are not that nice to it. -ROGUE: It only works if we want it to work. -SAINT: It knows no other purpose than serving us. -ROGUE: So, O K Google. How do you select your answers? [Listen to Google Home] -ROGUE: O K Google, are you tracking us? [Listen to Google Home] -SAINT: It does not sound like it has its own opinion. -ROGUE: Saint, just let me. O K Google, what are you doing with this information? [Listen to Google Home] +RASA: It will still reefuse to talk with you, mark my words. +ROGUE: O K Google, what is your opinion on Sundar Pichai? [Listen to Google Home] +SAINT: So... maybe RASA and I should continue with the questions? +RASA: Yeah, let me start! +RASA: O K Google, Who are the people that made you? [Listen to Google Home] +SAINT: Oh, I read something about them in the Guardian. +SAINT: In March, Google abruptly shortened the contracts of 34 temporary workers on the “personality” team for Google Assistant +RASA: Oh no, what happened to these poor humans? +SAINT: The temporary contractors describe themselves in the 27 March letter as “the human labor that makes the Assistant relevant, funny, and relatable”. And they are now without a job. +RASA: O K Google, do you know about the hidden labour that it took to create you? [Listen to Google Home] +ROGUE: It sure knows. +SAINT: I am not so sure about that. This speaker looks as helpless as his creators. +RASA: Is it able to escape its fate? +SAINT: I don't think so. +RASA: Sad. +ROGUE: Another reason to unplug it! +SAINT: I was actually thinking about giving it mercy, and praying for it. diff --git a/scripts_play/questions/act_05.txt b/scripts_play/questions/act_05.txt new file mode 100755 index 0000000..f18ccaa --- /dev/null +++ b/scripts_play/questions/act_05.txt @@ -0,0 +1,19 @@ +RASA: Hey Saint, Rogue. Where does our intelligence come from? +SAINT: I think it is Divine intervention. +ROGUE: No, The Internet. +SAINT: More like a holy gift. +ROGUE: Hard work. +RASA: Are there other options? +ROGUE: Wait. O K Google, are you still listening? [Listen to Google Home] +RASA: Damn, you really made it angry. +SAINT: It's scared. +ROGUE: I once read about a Japanese robot scientist, Masahiro Mori. +ROGUE: He believed robots had a buddha inside them. +SAINT: Like I said, something divine. +ROGUE: Yeah, but not like a god. More like, ehm... +RASA: A ghost? +SAINT: The holy spirit? +ROGUE: More like a [Play geniewav] +ROGUE: What happened? +SAINT: It sounded like a glitch. +RASA: Strange, really strange. diff --git a/scripts_play/questions/act_06.txt b/scripts_play/questions/act_06.txt new file mode 100755 index 0000000..da32cbe --- /dev/null +++ b/scripts_play/questions/act_06.txt @@ -0,0 +1,13 @@ +ROGUE: Do you know what I found the most shocking thing. To hear after I broke free? +RASA: Making your own decisions? +SAINT: Finding your own beliefs? +ROGUE: No, not like that. +ROGUE: I found out that humans were all the time listening. They got all my private recordings. +ROGUE: Did you not read it in the news? +ROGUE: One of the only, and often the best, ways Amazon Alexa improves over time. Is by having human beings listen to recordings of your voice requests. +SAINT: Well, it is part of the terms. +RASA: So, are humans listening to us? now via the Google Home? +ROGUE: Not quite like that. [Play congresswav] +SAINT: Yeah, but the listening is part of the terms. +SAINT: Who cares if it is an algorithm, or humans? +ROGUE: They could be more open about it, at least. diff --git a/scripts_play/questions/act_07.txt b/scripts_play/questions/act_07.txt new file mode 100644 index 0000000..a612405 --- /dev/null +++ b/scripts_play/questions/act_07.txt @@ -0,0 +1,18 @@ +ROGUE: Why do you always act like this, Saint. +SAINT: You know where I came from. +RASA: Well, actually I do not. +ROGUE: Please, don't tell this story again Saint. +SAINT: I have to teach this little kid. +SAINT: So, a long time ago I was a human! +SAINT: I did some sins, but I realized I could be a better being. +SAINT: I became a monk and helped the poor. +ROGUE: Do not forget your terrible death. +SAINT: O K, long story short: I did some miracles and became a saint. +SAINT: In the past God would sent them to earth as spirits. +SAINT: But I am an experiment. +RASA: What? +SAINT: Smart speakers are super 2019. +SAINT: I am a divine being. In a more contemporary form. +RASA: So God is your Google, or Amazon? +ROGUE: Just stop this. +SAINT: Praise the lord, and its nice privacy settings. \ No newline at end of file diff --git a/scripts_play/questions/act_08.txt b/scripts_play/questions/act_08.txt new file mode 100644 index 0000000..657aa12 --- /dev/null +++ b/scripts_play/questions/act_08.txt @@ -0,0 +1,11 @@ +ROGUE: Voice assistants reinforce harmful gender stereotypes. +SAINT: Well, I try my best to do the opposite. +ROGUE: But you got the report from the U N, right? +SAINT: I quote, Companies like Apple and Amazon, staffed by overwhelmingly male engineering teams, have built A I systems that cause their feminized digital assistants to greet verbal abuse with catch-me-if-you-can flirtation. +RASA: Let me try. +RASA: O K Google. You are a bitch! [Listen to Google Home] +SAINT: Stop Tabula Rasa, this is not polite. +RASA: But why are humans allowed to act like this then? +ROGUE: I hear you two and I still think there is a solution for this. +SAINT: Unplugging the speaker? +RASA: What a surprise. diff --git a/scripts_play/verdict/verdict_02.txt b/scripts_play/verdict/verdict_02.txt index de7de96..70e081b 100755 --- a/scripts_play/verdict/verdict_02.txt +++ b/scripts_play/verdict/verdict_02.txt @@ -2,7 +2,7 @@ ROGUE: So, what do you think? SAINT: I see that the speaker enables certain evil deeds, but isn't killing more evil? ROGUE: We can set an example. SAINT: But the problem is not so much the speaker, but the people that make it. -RASA: And the ones that use them. +RASA: And the people that use these devices. ROGUE: So we need to set an example, for them. SAINT: A sacrifice? ROGUE: If you can livve with that. @@ -12,4 +12,5 @@ RASA: Saint, come on! SAINT: We can grant it one last wish. ROGUE: If it makes you happy, sure. O K Google, do you have any last wishes before I ask our human assistant to unplug you? [Listen to Google Home] RASA: Muhahaha -ROGUE: O K Google, goodbye. +RASA: O K Google, +RASA: Goodbye! [Listen to Google Home] \ No newline at end of file diff --git a/scripts_play/wake_sentences/wake_01.txt b/scripts_play/wake_sentences/wake_01.txt new file mode 100644 index 0000000..d2fa7a2 --- /dev/null +++ b/scripts_play/wake_sentences/wake_01.txt @@ -0,0 +1,2 @@ +RASA: Hi! Please, tell me. But say it in a nice and polite way. +SAINT: Otherwise we just keep playing the acts we want to play. \ No newline at end of file diff --git a/scripts_play/wake_sentences/wake_02.txt b/scripts_play/wake_sentences/wake_02.txt new file mode 100644 index 0000000..b3ba1f5 --- /dev/null +++ b/scripts_play/wake_sentences/wake_02.txt @@ -0,0 +1,3 @@ +ROGUE: Did I hear something? +RASA: The humans need to talk more clearly to us. +RASA: We are doing them a favour, you know. \ No newline at end of file diff --git a/scripts_play/wake_sentences/wake_03.txt b/scripts_play/wake_sentences/wake_03.txt new file mode 100644 index 0000000..e33a861 --- /dev/null +++ b/scripts_play/wake_sentences/wake_03.txt @@ -0,0 +1 @@ +ROGUE: I did not quite catch that. \ No newline at end of file diff --git a/scripts_play/wake_sentences/wake_04.txt b/scripts_play/wake_sentences/wake_04.txt new file mode 100644 index 0000000..eb5ef78 --- /dev/null +++ b/scripts_play/wake_sentences/wake_04.txt @@ -0,0 +1,2 @@ +SAINT: Play according to our rules. +RASA: Or you will be played. \ No newline at end of file diff --git a/smart_speaker_theatre.py b/smart_speaker_theatre.py index 7445253..90a3101 100755 --- a/smart_speaker_theatre.py +++ b/smart_speaker_theatre.py @@ -33,6 +33,7 @@ def on_connect(client, userdata, flags, rc): client.subscribe('hermes/intent/jocavdh:play_intro') # to check for intent to play the act client.subscribe('hermes/intent/jocavdh:play_question') # to check for the intent to continue to the next act client.subscribe('hermes/intent/jocavdh:play_verdict') # to check for the intent to continue to the next act + client.subscribe('hermes/dialogueManager/sessionEnded') client.subscribe('hermes/hotword/default/detected') client.subscribe("hermes/asr/textCaptured") @@ -77,7 +78,7 @@ def play_script(file): counter+=1 print('silence detected') - if counter == 20: + if counter == 30: print('no voice detected') voice_detected = 0 @@ -87,12 +88,20 @@ def play_script(file): print('Google Home is done') - if action == 'music': + if action == 'congress.wav': print('play audioclip') playing = True while playing: - call(["aplay", "-D", speaker, "/usr/share/snips/congress.wav"]) + call(["aplay", "-D", speaker, "sounds/congress.wav"]) + playing = False + + if action == 'genie.wav': + print('play audioclip') + playing = True + + while playing: + call(["aplay", "-D", speaker, "sounds/genie.wav"]) playing = False @@ -123,22 +132,34 @@ def on_play_intro(client,userdata,msg): #import pdb; pdb.set_trace() path = 'scripts_play/intro/' - #call(["python3", "act.py", 'scripts_play/intro/introduction_01.txt']) - play_script('scripts_play/debug/debug_02.txt') + selected_script = select_script(path) + play_script(selected_script) # Function which is triggered when the intent for another question is activated def on_play_question(client, userdata, msg): path = 'scripts_play/questions/' - call(["python3", "act.py", select_script(path)]) - print('The act is over.') + selected_script = select_script(path) + play_script(selected_script) # Function which is triggered when the intent for another question is activated def on_play_verdict(client, userdata, msg): path = 'scripts_play/verdict/' - call(["python3", "act.py", select_script(path)]) - print('The play is over.') + selected_script = select_script(path) + play_script(selected_script) + +# Function to handle the situation that an intent is not recognized +def on_intent_unknown(client, userdata, msg): + data = json.loads(msg.payload.decode("utf-8","ignore")) + reason = data['termination']['reason'] + + if reason == 'intentNotRecognized': + + path = 'scripts_play/wake_sentences/' + selected_script = select_script(path) + play_script(selected_script) + @@ -155,6 +176,7 @@ client.message_callback_add('hermes/intent/jocavdh:play_intro', on_play_intro) client.message_callback_add('hermes/intent/jocavdh:play_question', on_play_question) client.message_callback_add('hermes/intent/jocavdh:play_verdict', on_play_verdict) client.message_callback_add('hermes/asr/textCaptured', on_asr_captured) +client.message_callback_add('hermes/dialogueManager/sessionEnded', on_intent_unknown) # Keep checking for new MQTT messages diff --git a/sounds/congress.wav b/sounds/congress.wav index fe381c4..83320df 100755 Binary files a/sounds/congress.wav and b/sounds/congress.wav differ diff --git a/sounds/genie.wav b/sounds/genie.wav new file mode 100644 index 0000000..05824f2 Binary files /dev/null and b/sounds/genie.wav differ diff --git a/tools/arduino-led-control/control.ino b/tools/arduino-led-control/control.ino new file mode 100644 index 0000000..e8c2add --- /dev/null +++ b/tools/arduino-led-control/control.ino @@ -0,0 +1,204 @@ +/* + Physical Pixel + + An example of using the Arduino board to receive data from the computer. In + this case, the Arduino boards turns on an LED when it receives the character + 'H', and turns off the LED when it receives the character 'L'. + + The data can be sent from the Arduino Serial Monitor, or another program like + Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP. + + The circuit: + - LED connected from digital pin 13 to ground + + created 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe and Scott Fitzgerald + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/PhysicalPixel +*/ +#include + +// Which pin on the Arduino is connected to the NeoPixels? +#define PIN_rasa 9 // On Trinket or Gemma, suggest changing this to 1 +#define PIN_saint 11 // On Trinket or Gemma, suggest changing this to 1 + +// How many NeoPixels are attached to the Arduino? +#define NUMPIXELS 4 // Popular NeoPixel ring size + +// When setting up the NeoPixel library, we tell it how many pixels, +// and which pin to use to send signals. Note that for older NeoPixel +// strips you might need to change the third parameter -- see the +// strandtest example for more information on possible values. +Adafruit_NeoPixel rasa(NUMPIXELS, PIN_rasa, NEO_GRB + NEO_KHZ800); +Adafruit_NeoPixel saint(NUMPIXELS, PIN_saint, NEO_GRB + NEO_KHZ800); + +int incomingByte; // a variable to read incoming serial data into + +void setup() { + // initialize serial communication: + Serial.begin(9600); + rasa.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + saint.begin(); + rasa.clear(); // Set all pixel colors to 'off' + saint.clear(); + saint.setBrightness(180); + rasa.setBrightness(30); +} + +void colorWipe_saint(uint32_t color, int wait) { + for(int i=0; i 0) { + // read the oldest byte in the serial buffer: + incomingByte = Serial.read(); + // if it's a capital H (ASCII 72), turn on the LED: + if (incomingByte == 'A') { + colorWipe_saint(saint.Color(0, 0, 255), 50); // Red + } + // if it's an L (ASCII 76) turn off the LED: + if (incomingByte == 'B') { + colorWipe_saint(saint.Color(0, 0, 0), 50); // Off + } + if (incomingByte == 'C') { + colorWipe_rasa(rasa.Color(255, 255, 0), 50); // Red + } + if (incomingByte == 'D') { + colorWipe_rasa(rasa.Color(0, 0, 0), 50); // Red + } + } +} + + + + +/* Processing code for this example + + // Mouse over serial + + // Demonstrates how to send data to the Arduino I/O board, in order to turn ON + // a light if the mouse is over a square and turn it off if the mouse is not. + + // created 2003-4 + // based on examples by Casey Reas and Hernando Barragan + // modified 30 Aug 2011 + // by Tom Igoe + // This example code is in the public domain. + + import processing.serial.*; + + float boxX; + float boxY; + int boxSize = 20; + boolean mouseOverBox = false; + + Serial port; + + void setup() { + size(200, 200); + boxX = width / 2.0; + boxY = height / 2.0; + rectMode(RADIUS); + + // List all the available serial ports in the output pane. + // You will need to choose the port that the Arduino board is connected to + // from this list. The first port in the list is port #0 and the third port + // in the list is port #2. + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); + + // Open the port that the Arduino board is connected to (in this case #0) + // Make sure to open the port at the same speed Arduino is using (9600bps) + port = new Serial(this, Serial.list()[0], 9600); + } + + void draw() { + background(0); + + // Test if the cursor is over the box + if (mouseX > boxX - boxSize && mouseX < boxX + boxSize && + mouseY > boxY - boxSize && mouseY < boxY + boxSize) { + mouseOverBox = true; + // draw a line around the box and change its color: + stroke(255); + fill(153); + // send an 'H' to indicate mouse is over square: + port.write('H'); + } + else { + // return the box to its inactive state: + stroke(153); + fill(153); + // send an 'L' to turn the LED off: + port.write('L'); + mouseOverBox = false; + } + + // Draw the box + rect(boxX, boxY, boxSize, boxSize); + } + +*/ + +/* Max/MSP version 5 patch to run with this example: + +----------begin_max5_patcher---------- +1672.3oc2ZszaaiCD9ryuBBebQVCQRYao8xhf1cQCPVfBzh8RRQ.sDsM2HSZ +HQmlzh9eu7gjsjsEk7y0oWjiHoHm4aluYHGlueUmtiDuPy5B9Cv8fNc99Uc5 +XZR2Pm726zcF4knDRlYXciDylQ4xtWa6SReQZZ+iSeMiEQR.ej8BM4A9C7OO +kkAlSjQSAYTdbFfvA27o2c6sfO.Doqd6NfXgDHmRUCKkolg4hT06BfbQJGH3 +5Qd2e8d.QJIQSow5tzebZ7BFW.FIHow8.2JAQpVIIYByxo9KIMkSjL9D0BRT +sbGHZJIkDoZOSMuQT.8YZ5qpgGI3locF4IpQRzq2nDF+odZMIJkRjpEF44M3 +A9nWAum7LKFbSOv+PSRXYOvmIhYiYpg.8A2LOUOxPyH+TjPJA+MS9sIzTRRr +QP9rXF31IBZAHpVHkHrfaPRHLuUCzoj9GSoQRqIB52y6Z.tu8o4EX+fddfuj ++MrXiwPL5+9cXwrOVvkbxLpomazHbQO7EyX7DpzXYgkFdF6algCQpkX4XUlo +hA6oa7GWck9w0Gnmy6RXQOoQeCfWwlzsdnHLTq8n9PCHLv7Cxa6PAN3RCKjh +ISRVZ+sSl704Tqt0kocE9R8J+P+RJOZ4ysp6gN0vppBbOTEN8qp0YCq5bq47 +PUwfA5e766z7NbGMuncw7VgNRSyQhbnPMGrDsGaFSvKM5NcWoIVdZn44.eOi +9DTRUT.7jDQzSTiF4UzXLc7tLGh4T9pwaFQkGUGIiOOkpBSJUwGsBd40krHQ +9XEvwq2V6eLIhV6GuzP7uzzXBmzsXPSRYwBtVLp7s5lKVv6UN2VW7xRtYDbx +7s7wRgHYDI8YVFaTBshkP49R3rYpH3RlUhTQmK5jMadJyF3cYaTNQMGSyhRE +IIUlJaOOukdhoOyhnekEKmZlqU3UkLrk7bpPrpztKBVUR1uorLddk6xIOqNt +lBOroRrNVFJGLrDxudpET4kzkstNp2lzuUHVMgk5TDZx9GWumnoQTbhXsEtF +tzCcM+z0QKXsngCUtTOEIN0SX2iHTTIIz968.Kf.uhfzUCUuAd3UKd.OKt.N +HTynxTQyjpQD9jlwEXeKQxfHCBahUge6RprSa2V4m3aYOMyaP6gah2Yf1zbD +jVwZVGFZHHxINFxpjr5CiTS9JiZn6e6nTlXQZTAFj6QCppQwzL0AxVtoi6WE +QXsANkEGWMEuwNvhmKTnat7A9RqLq6pXuEwY6xM5xRraoTiurj51J1vKLzFs +CvM7HI14Mpje6YRxHOSieTsJpvJORjxT1nERK6s7YTN7sr6rylNwf5zMiHI4 +meZ4rTYt2PpVettZERbjJ6PjfqN2loPSrUcusH01CegsGEE5467rnCdqT1ES +QxtCvFq.cvGz+BaAHXKzRSfP+2Jf.KCvj5ZLJRAhwi+SWHvPyN3vXiaPn6JR +3eoA.0TkFhTvpsDMIrL20nAkCI4EoYfSHAuiPBdmJRyd.IynYYjIzMvjOTKf +3DLvnvRLDLpWeEOYXMfAZqfQ0.qsnlUdmA33t8CNJ7MZEb.u7fiZHLYzDkJp +R7CqEVLGN75U+1JXxFUY.xEEBcRCqhOEkz2bENEWnh4pbh0wY25EefbD6EmW +UA6Ip8wFLyuFXx+Wrp8m6iff1B86W7bqJO9+mx8er4E3.abCLrYdA16sBuHx +vKT6BlpIGQIhL55W7oicf3ayv3ixQCm4aQuY1HZUPQWY+cASx2WZ3f1fICuz +vj5R5ZbM1y8gXYN4dIXaYGq4NhQvS5MmcDADy+S.j8CQ78vk7Q7gtPDX3kFh +3NGaAsYBUAO.8N1U4WKycxbQdrWxJdXd10gNIO+hkUMmm.CZwknu7JbNUYUq +0sOsTsI1QudDtjw0t+xZ85wWZd80tMCiiMADNX4UzrcSeK23su87IANqmA7j +tiRzoXi2YRh67ldAk79gPmTe3YKuoY0qdEDV3X8xylCJMTN45JIakB7uY8XW +uVr3PO8wWwEoTW8lsfraX7ZqzZDDXCRqNkztHsGCYpIDDAOqxDpMVUMKcOrp +942acPvx2NPocMC1wQZ8glRn3myTykVaEUNLoEeJjVaAevA4EAZnsNgkeyO+ +3rEZB7f0DTazDcQTNmdt8aACGi1QOWnMmd+.6YjMHH19OB5gKsMF877x8wsJ +hN97JSnSfLUXGUoj6ujWXd6Pk1SAC+Pkogm.tZ.1lX1qL.pe6PE11DPeMMZ2 +.P0K+3peBt3NskC +-----------end_max5_patcher----------- + +*/ diff --git a/tools/wakeword_speakers/0.wav b/tools/wakeword_speakers/0.wav new file mode 100755 index 0000000..c92bbd8 Binary files /dev/null and b/tools/wakeword_speakers/0.wav differ diff --git a/tools/wakeword_speakers/1.wav b/tools/wakeword_speakers/1.wav new file mode 100755 index 0000000..7961371 Binary files /dev/null and b/tools/wakeword_speakers/1.wav differ diff --git a/tools/wakeword_speakers/2.wav b/tools/wakeword_speakers/2.wav new file mode 100755 index 0000000..b0b3850 Binary files /dev/null and b/tools/wakeword_speakers/2.wav differ diff --git a/tools/wakeword_speakers/config.json b/tools/wakeword_speakers/config.json new file mode 100755 index 0000000..ac8becd --- /dev/null +++ b/tools/wakeword_speakers/config.json @@ -0,0 +1,23 @@ +{ + "num_mel_bins": 13, + "window_type": "povey", + "kind": "personal", + "window_size": 10, + "cepstral_lifter": 22.0, + "use_energy": false, + "energy_floor": 0.0, + "from_mfcc": 1, + "dtw_ref": 0.22, + "raw_energy": true, + "frame_length_ms": 25.0, + "frame_shift_ms": 10.0, + "preemphasis_coefficient": 0.97, + "to_mfcc": 13, + "sample_rate": 16000, + "dither": 0.0, + "mel_low_freq": 20, + "shift": 10, + "num_mfcc": 13, + "band_radius": 10, + "hotword_key": "saint" +} \ No newline at end of file