element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi Chef Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Pi Chef Design Challenge
  • More
  • Cancel
Pi Chef Design Challenge
Blog The Spice of Pi - Glenn Blog #8
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: glennvanderveer
  • Date Created: 25 Mar 2018 4:13 PM Date Created
  • Views 795 views
  • Likes 6 likes
  • Comments 2 comments
  • google voice hat
  • pi chef*
  • google aiy voice kit
  • google speech api
Related
Recommended

The Spice of Pi - Glenn Blog #8

glennvanderveer
glennvanderveer
25 Mar 2018

Another day, another blog...

 

So after getting the servos to work I found out that the pigpio library, although it works marvelously, kills the AIY voice control dead.  As soon as the service is started (with sudo pigpio command), the AIY microphone didn't hear what I was saying.  I have numbers android phones and tablets on my desk, and they all heard and responded to my Hey/OK Google attempts, but not the Voice Hat.  The only way to recover (even after doing a killall pigpio command) was to reboot. So I had to go back to the jittery gpiozero library.  I did find that there was a command to detach from the servo and that stopped the jittering completely.  So, when I start my code loop, the first thing i do is detach from the servo.  When I have to move the servo, I set the angle desired, and then sleep for 4 seconds to allow the servo to move.  By the time the sleep is done, the servo is in its proper spot and then it is detached from.  I also changed the frame width parameter from the default setting of 20 down to 10. That seemed to slow the jitter down.

 

Using the old-new library I figured out the proper angles to stop the servo at so that the lifter was as close as possible to the middle of the opening.  The video shows the voice activated control of the spinning platter.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

And here is the test code...

Code block

#!/usr/bin/env python3

import aiy.audio

import aiy.cloudspeech

import aiy.voicehat

from gpiozero import AngularServo

import time

 

 

def main():

    recognizer = aiy.cloudspeech.get_recognizer()

    recognizer.expect_phrase('meat')

    recognizer.expect_phrase('cheese')

    recognizer.expect_phrase('water')

    recognizer.expect_phrase('milk')

    recognizer.expect_phrase('toaster')

    recognizer.expect_phrase('oven')

    recognizer.expect_phrase('knife')

    recognizer.expect_phrase('spoon')

    recognizer.expect_phrase('pan')

    recognizer.expect_phrase('pepper')

    recognizer.expect_phrase('salt')

    recognizer.expect_phrase('spatula')

    recognizer.expect_phrase('sugar')

    recognizer.expect_phrase('basil')

    recognizer.expect_phrase('lemon')

    recognizer.expect_phrase('clove')

    button = aiy.voicehat.get_button()

    aiy.audio.get_recorder().start()

    #servo =AngularServo(6)

    s =AngularServo(6,min_angle=-180, max_angle=180,frame_width = 10/1000)

 

 

    while True:

        s.detach()

        print('Press the button and speak')

        button.wait_for_press()

        print('Listening...')

        text = recognizer.recognize()

        if text is None:

            print('Sorry, I did not hear you.')

        else:

            print('You said "', text, '"')

            if 'meat' in text:

                print('Moving servo to bottle one')

                s.angle=-176

              

                time.sleep(4)

                                                                                                                                                                                                                      

            elif'cheese'in text:

                print('Moving servo to bottle two')

                #servo.min()

                s.angle=-155

                time.sleep(4)

 

            elif'water'in text:

                print('Moving servo to bottle three')

                #servo.mid()

                s.angle=-135

                time.sleep(4)

  

            elif 'milk' in text:

                print('Moving servo to bottle four')

                #servo.mid()

                s.angle=-113

                time.sleep(4)

  

            elif'toaster'in text:

                print('Moving servo to bottle five')

                #servo.mid()

                s.angle=-95

                time.sleep(4)

  

            elif'oven'in text:

                print('Moving servo to bottle six')

                #servo.mid()

                s.angle=-73

                time.sleep(4)

 

            elif'knife'in text:

                print('Moving servo to bottle seven')

                #servo.mid()

                s.angle=-53

                time.sleep(4)

 

            elif'spoon'in text:

                print('Moving servo to bottle eight')

                #servo.mid()

                s.angle=-31

                time.sleep(4)

 

            elif'pan'in text:

                print('Moving servo to bottle nine')

                #servo.mid()

                s.angle=-18

                time.sleep(4)

 

            elif'pepper'in text:

                print('Moving servo to bottle ten')

                #servo.mid()

                s.angle=10

                time.sleep(4)

 

            elif'salt'in text:

                print('Moving servo to bottle eleven')

                #servo.mid()

                s.angle=36

                time.sleep(4)

 

            elif'spatula'in text:

                print('Moving servo to bottle twelve')

                #servo.mid()

                s.angle=58

                time.sleep(4)

 

            elif'sugar'in text:

                print('Moving servo to bottle thirteen')

                #servo.mid()

                s.angle=85

                time.sleep(4)

 

 

            elif'basil'in text:

                print('Moving servo to bottle fourteen')

                #servo.mid()

                s.angle=107

                time.sleep(4)

 

            elif'lemon'in text:

                print('Moving servo to bottle fifteen')

                #servo.mid()

                s.angle=129

                time.sleep(4)

          

            elif'clove'in text:

                print('Moving servo to bottle sixteen')

                #servo.mid()

                s.angle=151

                time.sleep(4)

 

 

if __name__ =='__main__':

    main()

 

Now to find the proper values for the lifting mechanism and activate the motion and lifting with an OK/Hey Google alert instead of using the push button.

 

Design Challenge Links:

Pi Chef Design Challenge

About the challenge

The other challengers

The kit

Terms & Conditions

Summaries by Charles Gantt

 

Project Links:

Blog Doug 1 - The Concept

Blog Glenn 1 - AIY Voice Kit Unboxing

Blog Doug 2 - The Block Diagram and Bill of Materials

Blog Doug 3 - Spice Jar Lift Mechanism

Blog Glenn 2 - Firmware Considerations

Blog Doug 4 - Carousel Design

Blog Doug 5 - Platter Rotation Mechanism

The Spice of Pi - Blog Glenn 3

Blog Doug 6 - 3D Printed Platter Parts

Blog Doug 7 - Main Drive Assembly

Blog Doug 8 - Working Carousel

Blog Doug 9 - Google Assistant

Blog Doug 10 - Pi Enclosure

The Spice of Pi - Glenn blog #4

The Spice of Pi - Glenn blog #5

The Spice of Pi - Glenn blog # 6

The Spice of Pi - Glenn Blog # 7

  • Sign in to reply

Top Comments

  • DAB
    DAB over 7 years ago +1
    Nice update. DAB
  • three-phase
    three-phase over 7 years ago +1
    Good to see the continued progress Kind regards
  • three-phase
    three-phase over 7 years ago

    Good to see the continued progress

     

    Kind regards

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Nice update.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube