Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

How to modify aiy audio driver to support 8KHz audio #486

Closed
titusece opened this issue Sep 10, 2018 · 4 comments
Closed

How to modify aiy audio driver to support 8KHz audio #486

titusece opened this issue Sep 10, 2018 · 4 comments
Labels

Comments

@titusece
Copy link

titusece commented Sep 10, 2018

Hello,
I have 8KHz sampling frequency supported audio file and want to use with aiy stuff, but seems it supports default 16KHz, how can I modify the aiy for 8KHz ?
https://github.com/google/aiyprojects-raspbian/blob/aiyprojects/src/aiy/_drivers/_recorder.py

def __init__(self, input_device='default',
             channels=1, bytes_per_sample=2, sample_rate_hz=16000):

TO

def __init__(self, input_device='default',
             channels=1, bytes_per_sample=2, sample_rate_hz=8000):

I did this, but it doesn't work, can you please help me out on this.
Thanks for the support.

@dmitriykovalev
Copy link
Contributor

_recorder.py is a class to record audio from the microphone to the file. You already have a file, right? How are you going to use your file?

@titusece
Copy link
Author

Hi,
Thanks for your reply.
I am using the following code and it uses the aiyprojects-raspian code.
https://github.com/senyoltw/DANBOARD/blob/master/mod/detect_intent_stream.py
I have audio mic which supports 8KHz only.

@dmitriykovalev
Copy link
Contributor

Looks like you are not using VoiceKit then. _recorder.py just generates arecord command line and executes it. You can try to run generated command line directly from the console and see what happens and how it fails.

self._cmd = [
'arecord',
'-q',
'-t', 'raw',
'-D', input_device,
'-c', str(channels),
'-f', 's%d' % (8 * bytes_per_sample),
'-r', str(sample_rate_hz),
]

@titusece
Copy link
Author

Thanks for the reply.
Modified this arecord stuff for my audio source and also modified the following file for 8KHz, then its working as expected.
https://github.com/senyoltw/DANBOARD/blob/master/mod/detect_intent_stream.py

    sample_rate_hertz = 8000

Thanks again.

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

No branches or pull requests

2 participants