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

Could not find PyAudio #389

Open
HAKANMAZI opened this issue Oct 16, 2020 · 9 comments
Open

Could not find PyAudio #389

HAKANMAZI opened this issue Oct 16, 2020 · 9 comments
Labels

Comments

@HAKANMAZI
Copy link

HAKANMAZI commented Oct 16, 2020

I installed chaquopy on my Android Studio then ı tried to run below code

import speech_recognition as sr
import time

r = sr.Recognizer()
mic = sr.Microphone()

def transcript(transcript=''):
    with mic as source:
        r.adjust_for_ambient_noise(source)
        audio = r.listen(source)
    try:
        transcript = r.recognize_google(audio,language='tr-TR')
    except sr.UnknownValueError:
        time.sleep(1)
    except sr.RequestError:
        time.sleep(1)

    return transcript

But I got this error

     Caused by: com.chaquo.python.PyException: AttributeError: Could not find PyAudio; check installation
        at <python>.speech_recognition.get_pyaudio(__init__.py:110)
        at <python>.speech_recognition.__init__(__init__.py:79)
        at <python>.konus.<module>(konus.py:5)
        at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:219)
        at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:783)
        at <python>.java.android.importer.exec_module(importer.py:549)
        at <python>.java.android.importer.exec_module(importer.py:594)
        at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:671)
        at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:975)
        at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:991)
        at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1014)
        at <python>.importlib.import_module(__init__.py:127)
        at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:156)
        at com.chaquo.python.Python.getModule(Native Method)
@mhsmith
Copy link
Member

mhsmith commented Oct 17, 2020

Thanks for the report. Unfortunately Android doesn't support any of the standard Linux audio APIs, so I think PyAudio / PortAudio would require a new backend in order to work.

If anyone else needs this package, please click the thumbs-up button above and subscribe to this issue, and we may look into it in the future.

@askinucuncu
Copy link

Is there any progress on this subject?

@mhsmith
Copy link
Member

mhsmith commented May 3, 2021

Not yet, sorry.

@MalikSayriii
Copy link

MalikSayriii commented May 11, 2021

After three days of searching a solution i came to know that it is not compatible with android studio 🥲 i am a beginner/student i wanted to implement PayAudio in my Final year project.. my request is to please make it possible...
I there any alternative i can use with my android app ?

@mhsmith
Copy link
Member

mhsmith commented May 11, 2021

You can use the standard Android audio APIs directly, either in Java, Kotlin, or in Python using the Chaquopy API. For an example, see here.

@nguyentiem
Copy link

i think our goal is to convert speech to text real time. so i have an idea, we pass bytes array as agrument of python function, then python function detect and return text to android . Is this solution possible?

@mhsmith
Copy link
Member

mhsmith commented Nov 9, 2022

Yes, that should be possible. But I don't think we currently support any Python packages which can decode compressed audio, unless there's a pure-Python option I don't know abot. So you'd have to pass the audio as an uncompressed WAV file, or raw PCM.

@ObscurusGrassator
Copy link

After 3 years any progress?

Chaquopy version 15.0.1

MacOS 13.5.2

Relevant parts of your build.gradle file

chaquopy {
    defaultConfig {
        version = "3.9"
        buildPython("/Users/xxx/.pyenv/versions/3.9.18/bin/python")
        pip {
            install "tflite_runtime-2.5.0.post1-cp39-cp39-macosx_12_0_arm64.whl"
            install "pyaudio"
            install "openwakeword"
            // https://test.pypi.org/simple/onnxruntime/
            install "onnxruntime-1.16.2-cp39-cp39-macosx_11_0_arm64.whl"
        }
    }
}
android {
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"

Describe your issue

...
Collecting pyaudio
  Using cached PyAudio-0.2.14.tar.gz (47 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
...
  ERROR: Command errored out with exit status 1:
   command: .../android/app/build/python/env/debug/bin/python .../android/app/build/python/env/debug/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/zd/fmk31xcn1q3b09jlpc14k3g00000gn/T/tmp1g_drf5v
       cwd: /private/var/folders/zd/fmk31xcn1q3b09jlpc14k3g00000gn/T/pip-install-sfda6ys4/pyaudio
  Complete output (10 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-13.5-arm64-cpython-39
  creating build/lib.macosx-13.5-arm64-cpython-39/pyaudio
  copying src/pyaudio/__init__.py -> build/lib.macosx-13.5-arm64-cpython-39/pyaudio
  running build_ext
  building 'pyaudio._portaudio' extension
  error: CCompiler.compile: Chaquopy cannot compile native code
  ----------------------------------------
ERROR: Failed to install pyaudio from https://files.pythonhosted.org/packages/26/1d/8878c7752febb0f6716a7e1a52cb92ac98871c5aa522cba181878091607c/PyAudio-0.2.14.tar.gz#sha256=78dfff3879b4994d1f4fc6485646a57755c6ee3c19647a491f790a0895bd2f87.
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
Chaquopy: Exit status 1

FAILURE: Build failed with an exception.
...

@mhsmith
Copy link
Member

mhsmith commented Jan 17, 2024

No, because as I said above, this would require a substantial amount of work on PyAudio's side.

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

No branches or pull requests

6 participants