xiongyihui / python-webrtc-audio-processing

Python bindings of WebRTC Audio Processing
167 stars 51 forks source link

TypeError: in method 'AudioProcessingModule_process_stream', argument 2 of type 'std::string const &' #3

Closed bjtommychen closed 5 years ago

bjtommychen commented 5 years ago

TypeError: in method 'AudioProcessingModule_process_stream', argument 2 of type 'std::string const &'

xiongyihui commented 5 years ago

Can you provide the information of your OS, python and swig?

bjtommychen commented 5 years ago

ubuntu 16.04 Python 3.5.2 SWIG Version 3.0.12 Compiled with g++ [x86_64-pc-linux-gnu] Configured options: +pcre

thanks.

bjtommychen commented 5 years ago

@xiongyihui follow your guide, python2 run OK. but python3 failed. would you give me some clue? thank.s

xiongyihui commented 5 years ago

Tried to reproduce it, but it works with python3 on my Ubuntu 16.04

mkdir sandbox && cd sandbox
python3 -m venv venv
. venv/bin/activate
pip3 install wheel
pip3 install webrtc-audio-processing
wget https://github.com/xiongyihui/python-webrtc-audio-processing/raw/master/examples/wav_ns.py
arecord -f S16_LE -c 1 -r 16000 -v mono16k.wav
python3 wav_ns.py mono16k.wav out.wav
aplay -v out.wav 

Can you try these commands?

bjtommychen commented 5 years ago

@xiongyihui, thanks for your quick answer. I follow your commands. got same error as below. I doubt it may caused by the python3 version. Please help to figure it out. Thanks. Which python3 version you use ?

python3 --version Python 3.5.2

~/d/sandbox$ python3 wav_ns.py ~/d/mono16k.wav out.wav Traceback (most recent call last): File "wav_ns.py", line 37, in data_out = ap.process_stream(data) File "/data/tommy_data/sandbox/venv/lib/python3.5/site-packages/webrtc_audio_processing/webrtc_audio_processing.py", line 82, in process_stream def process_stream(self, args): return _webrtc_audio_processing.AudioProcessingModule_process_stream(self, args) TypeError: in method 'AudioProcessingModule_process_stream', argument 2 of type 'std::string const &'

xiongyihui commented 5 years ago

My python version is also 3.5.2

Maybe it is a problem of swig. I compiled and installed swig from source code. How do you install swig?

xiongyihui commented 5 years ago

You can test the pre-compiled wheel package.

wheel.tar.gz

bjtommychen commented 5 years ago

@xiongyihui I installed swig using apt. Thank you very much. the wheel work ! I can continue my test, thanks again.

lianrzh commented 4 years ago

@xiongyihui Is there a python3.7.3 wheel package? I have the same problem.

xiongyihui commented 4 years ago

@lianrzh I don't have one. You can try installing the latest swig (build it from source), and then build this package.

hysaaron commented 4 years ago

Got same problem, python 3.6, latest webrtc_audio_processing, latest swig (installed from source code), CentOS. Failed to install https://github.com/xiongyihui/python-webrtc-audio-processing/files/2790352/wheel.tar.gz Is there any other way solving it? Thanks!

dragen1860 commented 2 years ago

+1

marianasignal commented 1 year ago

got same problem,hope for a solution or an updating.

ubuntu 18.04 Python 3.7.13 SWIG Version 4.0.2 Compiled with g++ [x86_64-pc-linux-gnu] Configured options: +pcre

marianasignal commented 1 year ago

i just resolve it by covert string to bytest:

audio_10ms = '\0' 160 2 audio_out = ap.process_stream(bytes(audio_10ms, encoding='utf-8'))