Analog Audio not working


#1

Can’t get any audio to come out of my gopigo3 using Raspbian for robots.
Anyone else had this issue?


#2

How I setup audio for my GoPiGo3 “Carl” robot:

=== raise the sound playback, and capture levels
alsamixer (h for help)
8 to set playback to 85%
s select USB PnP Sound Device
Tab till [Capture] is highlighted
8
up arrow once to 81%
Esc to exit alsamixer
alsactl store 0 to save settings

=== Test audio

aplay /usr/share/sounds/alsa/*

if no audio:
amixer to see what is current setting: (0=auto, 1=analog, 2=HDMI)

sudo amixer cset numid=3 1 (set to output sound to 3.5mm jack

try again:
aplay /usr/share/sounds/alsa/*

========== If audio output is too soft =======
if soft: alsamixer
s (select card)
downarrow to “0 bcm2835 ALSA”
8 (4=default loudness, 8=100%, 9=125%)
Escape (press Esc)
then make setting default:
sudo alsactl store 0

==== espeak is already installed in Raspbian for Robots

# This is my speak.py module containing  say(phrase) function:
'''
#!/usr/bin/python
#
# speak.py   Speaker utilities
#
#  say(phrase)    (includes safe use of apostrophe in quoted strings and quotes in apostrophed strings)

import subprocess

def say_espeak(phrase):
    phrase = phrase.replace("'","")
    phrase = phrase.replace('"',' quote ')
    subprocess.check_output(['espeak -ven+f3 -s200 "%s"' %  phrase], stderr=subprocess.STDOUT, shell=True)

def say(phrase):
    say_espeak(phrase)

# ##### MAIN ####
def main():
    # say("hello from speak dot p y test main")
    # say_espeak("whats the weather, long quiet?")
    say("This phrase contains an apostrophe which isn't allowed")
    say('This phrase contains "a quoted word" ')
    say("My name is Carl. I don't know Pogo.  Never met the little bot")

if __name__ == "__main__":
    main()

The next to last line is:

if __name__ == “__main__”:

make sure the double underscores are there.


#3

Thanks @RobertLucian - One of these days the triple back quote markup will stick in my brain.


#4

No problem :slight_smile:. I know it’s kinda counterintuitive, so it can be confusing at times.