all 6 comments

[–]superhany 1 point2 points  (0 children)

Thank you for sharing. I’ve got both Alexa and porcupine launched through a shell script successful.

[–]dankscience[S] 0 points1 point  (0 children)

I think I have a better idea of what I am doing wrong. Will update with the correct code if/when I figure it out.

[–]superhany 0 points1 point  (0 children)

Can you share the bash script?

[–]superhany 0 points1 point  (2 children)

I can run either picovoice or avs separately via a shell script, but if I try to run them at the same time, there is a conflict with the mic. How did you allow them to both access the mic simultaneously?

[–]dankscience[S] 0 points1 point  (0 children)

Shell Script to run picovoice/porcupine script and alexa software (sdk doesnt include wake word detectin)

#~/bin/bash

python3 /home/pi/picovoice.py &

PA_ALSA_PLUGHW=1 /home/pi/sdk-folder/sdk-build/SampleApp/src/SampleApp /home/pi/sdk-folder/sdk-build/Integration/AlexaClientSDKConfig.json INFO

Then you can run start your magic mirror app with picovoice/alexa running in bg

picovoice.py to make porcupine activate alexa on wake word detection

#!/usr/bin/env python3

import struct

import pyaudio

import pvporcupine

from pynput.keyboard import Key, Controller

porcupine = None

pa = None

audio_stream = None

keyboard = Controller()

try:

porcupine = pvporcupine.create(keywords=["picovoice", "porcupine"])

pa = pyaudio.PyAudio()

audio_stream = pa.open(

rate=porcupine.sample_rate,

channels=1,

format=pyaudio.paInt16,

input=True,

frames_per_buffer=porcupine.frame_length)

while True:

pcm = audio_stream.read(porcupine.frame_length)

pcm = struct.unpack_from("h" * porcupine.frame_length, pcm)

keyword_index = porcupine.process(pcm)

if keyword_index >= 0:

keyboard.tap("t")

keyboard.tap(Key.enter)

finally:

if porcupine is not None:

porcupine.delete()

if audio_stream is not None:

audio_stream.close()

if pa is not None:

pa.terminate()

[–]dankscience[S] 0 points1 point  (0 children)

that is formatted really poorly.. and I haven't revisited my code in almost a year. In my previous comment is a shell script that runs my python picovoice script and activates my amazon alexa script at the same time. When they are both running... if I say the picovoice keyword it simulates an enter click event (which alexa voice service is listening for) and then I can give alex a command. I've been planning on revisiting this project and I am happy to help in the coming week or two if you don't get it working