Use of Acapela tags with Nao robot - nao-robot

I am writing a program in python, where I want to use Acapela tags (as it is supported by naoqi). Please give a simple example, how to use Acapela tags in speech with Nao robot.

If you check the docs you will see that using the tags is really simple.
For example, if you want to make the robot say the sentence "Hello World. I am alive" with a pause between both statements, you have to introduce the tag \pau=300\ after the dot:
sentence = 'Hello World.\\pau=300\\ I am alive'
The double \\ is used in Python to scape the \ character.

Related

IRC(Twitch chat) Text-to-speech

Hey everyone I'm looking for a way to code a program/bot in VB that would read my chat, but only if a command is used
For example: "!tts Hello"
And It would read it using TTS and show it on screen
$USERNAME$ !tts: Hello
Now the thing I don't know how to set up is the program reading the chat, printing it on screen I believe is the easy part.
Also if it's possible to add an option to select to which audio output it will go.
You need to study more coding...
Im not a master at it myself. but i would make a boolean that could be true if the first letter in a chatline is a "!". And then a command that would add that line to a text-to-speech module

I'm having trouble making a more complex chatbot in notepad

Here is a part of my current (working) chatbot code in Notepad so you can get an idea of how I am coding it:
dim n, q
n=inputbox("Hello, I'm a chatbot. What is your name?")
q=inputbox(""& n &" is a great name! Thank you for activating me, "& n &"! How are you?")
I want to be able to make "if and else" parts (for example, if "happy" is typed in after being asked "How are you feeling" it should say "great", if you type anything else it would say something differently.) How do I do this in Notepad?
Also, how do I get it to loop and say something based on keywords (like how Eliza the chatbot will keep talking for infinity just by looping and referring to a bank of keywords and responses) in Notepad?
I know these are really basic questions, but I have have searched the web multiple times; all searches ending up empty handed.
Unfortunately, you asked a very inspecific question making it hard to answer. That is why your post received a downvote and a close down request. However, you seem enthousiastic and I can only encourage that.
First of all, VBScript is not a very nice language. Oh, yes it seems simple, it nicely integrates with some standard windows components and you can run it out of the box. But it is ancient and does some things differently than more common languages. If you want to do more complex things faster, ultimately you'd switch to another (scripting) language.
With VBScript it is not (easily) possible to use notepad as input/output device. For your setup I'd prefer the command line (press your windows key and enter CMD+enter, there it is).
You can write output to the command line with
WScript.StdOut.Write "What is your name?"
You can retrieve output from the command line with
wscript.stdin.read(0)
name = wscript.stdIn.readline()
And to make your chatbot complete:
WScript.StdOut.Write "Hello " & name
Now you want to do some conditional branching. Well, I do not say W3Schools is a very good resource, but for now it is sufficient. Look at their if ... then ... else page (<- clickable link). If you are using IE, you can even try some things yourself.
Finally you can use Do While ... Loop's to make the code repeat itself.
A chatbot like Eliza is a prestigeous project. Don't be discouraged if you only can build a very simple version. The cake is in the coding, not the result.

Line Break in Programming

Using \n represents line breaks in all programming languages I know of. But when it is used to write string to txt file, there is either \n written or replaced by some symbol or other element when viewed under notepad.. But other text editors such as Notepad++, Kate etc display fine.
What is the reason for this discrepancy?
Can I make the program e.g. C to write line breaks so that notepad itself displays as line break and not some symbol in between?
P.S. Everyone should have experienced this sometime in programming life. Who used windows.
You'll need a \r\n for Notepad in windows. Notepad++ and Kate are far better editors that are \r\n and \n aware and display the line break as you would like, or as you configure them.

Unable to put a simulation in C to a webpage

I have the following simulation in C for cars in a traffic circle
alt text http://dl.getdropbox.com/u/175564/cars.png
For example,
7 <space> <enter>
gives more cars to the simulation, while
s1 <enter>
puts a top sign to the incoming road #1.
I want to put the simulation to an internet page such that users can try it.
However, I do not know where I should start.
I know Joomla and little about Django. Perhaps, they can be useful.
How can you put a C program to a Webpage such that users can use it?
CGI is what you want; it will let you embed any program you want into a website, it was made for that purpose. Then perhaps embedding a few more options with PHP and HTML will let the user acutally input data into the program via the web. It should not be too hard.
Take a look here for more info: http://www.cs.tut.fi/~jkorpela/perl/cgi.html
I think that is a good pointer in the right direction. I hope that helps.
You could run the C code in a flash app using alchemy:
http://labs.adobe.com/technologies/alchemy/
Here's a good intro to writing CGIs in C: http://www.cs.tut.fi/~jkorpela/forms/cgic.html
However, since you're a beginner, I'd recommend porting your program to PHP. It's a very easy language to pick up, and it's a much easier route than writing a CGI in C.
I assume the C program needs input while it's running and not via command-line arguments? If I'm wrong, you can just use PHP and shell_exec() to run the program. The function returns anything printed to stdout.
Such a page might look like:
$sim = shell_exec("/path/to/binary -a 5 -b 6");
echo $sim;
Where the string passed to shell_exec is exactly what you'd type on the command line.
If you want a dynamic simulation, where the cars moves while you watch , you'll need an applet or flash.
A cgi program renders the page on each http GET/POST (on reload, submit etc)
and that is probably not what you want.
I would start with a flash or java applet wrapper. You can communicate with your application over a tcp connection and display the results in the flash or applet.
I would recommend going with sockets. If your C program could set up and listen on a local or internet socket, you could use the socket facilities in any language to send it arguments and get output.
If that's going to be too much of a pain, have php exec the program while directing the output to some file. Then, have php read that file.
Looking at the output of your program, I think trying to print the results of shell_exec() will result in clobbered output.
So, you could shell_exec("/bin/program -arguments > /tmp/prog-tmp.txt") , then read prog-tmp.txt.

Auto-indent spaces with C in vim?

I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks?
So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a } will shift back 2 spaces?
These two commands should do it:
:set autoindent
:set cindent
For bonus points put them in a file named .vimrc located in your home directory on linux
I wrote all about tabs in vim, which gives a few interesting things you didn't ask about. To automatically indent braces, use:
:set cindent
To indent two spaces (instead of one tab of eight spaces, the vim default):
:set shiftwidth=2
To keep vim from converting eight spaces into tabs:
:set expandtab
If you ever want to change the indentation of a block of text, use < and >. I usually use this in conjunction with block-select mode (v, select a block of text, < or >).
(I'd try to talk you out of using two-space indentation, since I (and most other people) find it hard to read, but that's another discussion.)
A lot of vim's features (like autoindent and cindent) are turned off by default. To really see what vim can do for you, you need a decent ~/.vimrc.
A good starter one is in $VIMRUNTIME/vimrc_example.vim. If you want to try it out, use
:source $VIMRUNTIME/vimrc_example.vim
when in vim.
I'd actually suggest just copying the contents to your ~/.vimrc as it's well commented, and a good place to start learning how to use vim. You can do this by
:e $VIMRUNTIME/vimrc_example.vim
:w! ~/.vimrc
This will overwrite your current ~/.vimrc, but if all you have in there is the indent settings Davr suggested, I wouldn't sweat it, as the example vimrc will take care of that for you as well. For a complete walkthrough of the example, and what it does for you, see :help vimrc-intro.
Simply run:
user#host:~ $ echo set autoindent >> .vimrc
I think the best answer is actually explained on the vim wikia:
http://vim.wikia.com/wiki/Indenting_source_code
Note that it advises against using "set autoindent." The best feature of all I find in this explanation is being able to set per-file settings, which is especially useful if you program in python and C++, for example, as you'd want 4 spaces for tabs in the former and 2 for spaces in the latter.
and always remember this venerable explanation of Spaces + Tabs:
http://www.jwz.org/doc/tabs-vs-spaces.html
Try:
set sw=2
set ts=2
set smartindent

Resources