Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform independent audio output. Stop hardcoding /home/jasper. #100

Merged
merged 8 commits into from
Jul 11, 2014

Conversation

astahlman
Copy link
Contributor

Summary

This commit includes changes to support platform independence. This implementation detects the current platform and chooses an appropriate system command for audio output. It also does not rely on a directory structure rooted at /home/pi

Changes

  1. Use $JASPER_HOME as base directory instead of assuming that root is /home/pi. This change is backwards-compatible, as the boot script will export $JASPER_HOME=/home/pi if this directory exists. On OS X, I set this environment variable in my ~/.zshrc.
  2. Abstracted out the 'say' functionality into the new speaker module. The speaker module will select one of two implementations based on the detected platform: RPi, which still uses espeak, or OS X, which uses the built-in say command.
  3. Updated boot/test.py to validate the list of vocabulary words passed to g2p without respect to ordering.

Testing

  • Manual verification on both OS X and the RPi.
  • Unit tests in boot/test.py and client/test.py pass on the RPi.

Notes

I wanted to minimize the scope of the changes included in this pull request, so I didn't mess with the directory structure. I was uneasy, however, appending client/ to the path in order to import the speaker module from inside boot/boot.py. What do others think should be the right approach here?

@vicramon
Copy link

The tests all pass on my Mac (10.9.3), but Japser is not recognizing any audio input once I boot it up. Did you do anything special to configure your microphone @astahlman?

@astahlman
Copy link
Contributor Author

Hmmm, weird. No, the microphone didn't need any extra set up for me. (10.7.5)

@@ -12,6 +16,10 @@

import g2p

class ListWhereOrderDoesNotMatter(list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can this be named UnorderedList?

@charliermarsh
Copy link

This is good stuff. I still need to test it out, but I've left some comments above. Hopefully we're not too far away from a merge here. Thanks!

@astahlman
Copy link
Contributor Author

Thanks. All good suggestions @crm416 - see the latest diff.

@charliermarsh
Copy link

Thanks for the quick turnaround. @shbhrsaha and I will try to test this before the end of the weekend.

@wadefletch
Copy link

Speaking of Platform-Independance, I have almost everything except audio input (thus requiring the use of local_mic) working on the Pythonista iOS app, but my TTS is a female voice named Jasper. Theoretically I could use an online TTS engine, but it would increase latency dramatically. If anyone knows about audio input on Pythonista or better iOS TTS it would be greatly appreciated.

@shbhrsaha
Copy link
Member

This is great work, @astahlman .

Just one thing: on my Pi, your implementation works if I run boot.sh manually, but doesn't seem to work when Jasper boots via cron. main.py simply doesn't start.

I believe the problem lies in the bash conditional statements in boot.sh. To diagnose this, I removed the conditional statements and forced the JASPER_HOME variable to be set, after which main.py started up fine during boot.

Unfortunately I don't have a monitor so can't provide more cron output, and my limited Bash/cron knowledge can't offer a specific solution. Can you confirm that your implementation works on the Pi as it boots, in addition to running boot.sh manually?

@astahlman
Copy link
Contributor Author

Good catch, @shbhrsaha. I disabled the automatic startup on my Pi so I didn't notice during testing. See the latest commit - I added a shebang at the beginning of the script to designate bash as the interpreter. Jasper now starts up successfully on reboot of the Pi.

@shbhrsaha
Copy link
Member

Excellent. I'll get a chance to test this out in the next few days and will report back and merge this in if it's all good!

@jessecooper
Copy link

I did this to my fork as well. I use $HOME for the system calls and in the shell scripts.

shbhrsaha added a commit that referenced this pull request Jul 11, 2014
Platform independent audio output. Stop hardcoding /home/jasper.
@shbhrsaha shbhrsaha merged commit bca2361 into jasperproject:master Jul 11, 2014
@shbhrsaha
Copy link
Member

Great, thanks! Merged into master and your contribution acknowledged in the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants