I writing app in python that uses pocketsphinx and pjsip
I use pocketsphinx keyword search to wakeup the app and pjsip as phone
the problem is when I try call the "call" function and after that returning to listen to the keyword and then I get an error message from pjsip that he cannot open the sound device:
pjsua_aud.c ..Opening sound device (speaker + mic) PCM#16000/1/20ms
alsa_dev.c ...ALSA lib pcm_hw.c:1557:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0c' failed (-16): Device or resource busy
pjsua_aud.c ..Unable to open sound device: Unknown error from audio driver (PJMEDIA_EAUD_SYSERR) [status=420002]
operation=make_call(), error=Unknown error from audio driver (PJMEDIA_EAUD_SYSERR)
this error only happens when i try to return to the keyword function that uses alsaaudio
so my question will be how I can open the same audio device with pjsip and alsaaudio?
Related
I am trying to capture from a streaming IP cam with username and password and port like so:vs = cv2.VideoCapture('http://user:password#ipadress:port/video.cgi?.mjpg')
but when I run the script I get this error in the cmd output:
[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (116) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): http://user:password#ipadress:port/video.cgi?.mjpg in function 'cv::icvExtractPattern'
things I tried:
-installing FFmpeg and directing it to the environment path
-trying different ports
-switching between HTTP and RTSP
obviously, I'm new. thank you.
At the moment, my networking team is downloading a firmware version using an FTP server (Filezilla).
We create an account on the server, upload the firmware to the server and then on the cisco device we use the command copy ftp://username:password#server_ip/file_name storage_device: and the device is downloading the firmware from the ftp server.
Now, i have a website created with Flask in python, that has some scripts that my team uses, and i want to add a script that allows the user to upload a file to the website, supply the ip of the device, and the script will connect to the device and pull the file from the server.
While creating an ftp server using pyftpdlib, i have encounterd some issues, as the device is logging in with the supplied user, but does not download the file.
If i log in to the server using an FTP client (FileZilla client) i can download the file separately.
I guess the issue is with the cisco device trying to download the firmware directly while connecting.
The code I used to create the python server:
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
def main():
authorizer = DummyAuthorizer()
authorizer.add_user('username', 'password', '/ftp', perm='elradfmwMT')
handler = FTPHandler
handler.authorizer = authorizer
handler.banner = "Test FTP server"
address = ('0.0.0.0', 21)
server = FTPServer(address, handler)
server.max_cons = 256
server.max_cons_per_ip = 10
server.serve_forever()
if __name__ == '__main__':
main()
If anyone has encounterd any issue like that, help would be appreciated.
Thank you!
Two possible issues:
1. Watch the diskspace on the IOS device. Some platforms have very little space for extra images, so good image hygiene is essential.
2. In my various experiments, I've found that pushing the image to the device is generally more reliable than asking the device to pull the image from elsewhere. You may need to add a configuration entry "ip scp server enable". Then you can write your script to push the images diretly.
I am working on a Python script to search for bluetooth devices and connect them using RFCOMM. This devices has Passkey/Password. I am using PyBlueZ and, as far as I know, this library cannot handle Passkey/Password connections (Python PyBluez connecting to passkey protected device).
I am able to discover the devices and retrieve their names and addresses:
nearby_devices = bluetooth.discover_devices(duration=4,lookup_names=True,
flush_cache=True, lookup_class=False)
But if tried to connect to a specific device using:
s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
s.connect((addr,port))
I get an error 'Device or resource busy (16)'.
I tried some bash commands using the hcitool and bluetooth-agent, but I need to do the connection programmatically. I was able to connect to my device using the steps described here: How to pair a bluetooth device from command line on Linux.
I want to ask if someone has connected to a bluetooth device with Passkey/Password using Python. I am thinking about to use the bash commands in Python using subprocess.call(), but I am not sure if it is a good idea.
Thanks for any help.
Finally I am able to connect to a device using PyBlueZ. I hope this answer will help others in the future. I tried the following:
First, import the modules and discover the devices.
import bluetooth, subprocess
nearby_devices = bluetooth.discover_devices(duration=4,lookup_names=True,
flush_cache=True, lookup_class=False)
When you discover the device you want to connect, you need to know port, the address and passkey. With that information do the next:
name = name # Device name
addr = addr # Device Address
port = 1 # RFCOMM port
passkey = "1111" # passkey of the device you want to connect
# kill any "bluetooth-agent" process that is already running
subprocess.call("kill -9 `pidof bluetooth-agent`",shell=True)
# Start a new "bluetooth-agent" process where XXXX is the passkey
status = subprocess.call("bluetooth-agent " + passkey + " &",shell=True)
# Now, connect in the same way as always with PyBlueZ
try:
s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
s.connect((addr,port))
except bluetooth.btcommon.BluetoothError as err:
# Error handler
pass
Now, you are connected!! You can use your socket for the task you need:
s.recv(1024) # Buffer size
s.send("Hello World!")
Official PyBlueZ documentation is available here
Is there a way to connect two phones via Bluetooth , the script should be running on a Linux host. Any suggestions of using pybluez or any other APIs?
I have seen some examples where a Linux host is used as Client and is connect a phone (which is a server), but here I'm want to use Linux host as just a device to run the script and make two phones connect via Bluetooth.
Trying to get the PYO music module to work on my Chromebook (Chroot Dev) (ARM7 processor) (Precise Penguin/ubuntu 12.04)
pyo:
>>>import pyo
pyo version 0.7.7 (uses single precision)
>>>pyo.Server(audio='jack').boot()
Due to the ARM processor and Precise some small modifications to the dependencies were necessary:
1] ARM changes to /proc/cpuinfo in relation to Jackd2, error:
FATAL: cannot locate cpu MHz in /proc/cpuinfo
solution? The error changed after, but not knowledgeable enough to know if for the better.
2] xwPython3.0 not available for Precise:
solution, shouldn't be a problem as this is UI dependency correct?
And to this is where the error is now:
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2015 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
/usr/local/bin/jackd: symbol lookup error: /usr/local/bin/jackd: undefined symbol: jackctl_driver_params_parse
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Jack error: Unable to create JACK client
jack_client_close called with a NULL client
Server not booted.
<pyolib.server.Server object at 0x1671150>
None of the solutions to any of the error messages i managed to find on google changed this error message. (google googled other, but you don't care about my messy internet history)
pulseaudio:
>pulseaudio --start
E: [pulseaudio] main.c: Daemon startup failed.
Could this be the main problem as Precise and the ChromeOS are running sidebyside and this causes a lock on the Deamon?
>pulseaudio --kill
E: [pulseaudio] main.c: Failed to kill daemon: No such process
>sudo pulseaudio --kill
E: [pulseaudio] core-util.c: Home directory /home/USERNAME not ours.
E: [pulseaudio] main.c: Failed to kill daemon: Permission denied
sudo permission denied??? PulseAudio running in ChromeOS???
jackd:
>jack_control start
Traceback (most recent call last):
File "/usr/local/bin/jack_control", line 399, in <module>
main()
File "/usr/local/bin/jack_control", line 158, in main
bus = dbus.SessionBus()
File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 211, in __new__
mainloop=mainloop)
File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
This just doesn't work cause i "don't have a display" for Jackd to open up in right?
Solution 1: Connecting JACK to CRAS instead of ALSA, probably what you want unless you want to disconnect ChromeOS from audio (open link from solution 2 for more information)
Solution 2: Connecting ALSA and JACK directly to hardware by turning off CRAS
I'm trying to play midi sounds from my python program on a RaspberryPi, however when trying to initialise fluidsynth, it errrors:
>>> import fluidsynth
>>> import time
>>> fs = fluidsynth.Synth()
>>> fs.start()
Causes the following errors:
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.9
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2012 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot lock down 82278944 byte memory area (Cannot allocate memory)
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
fluidsynth: error: Failed to connect to Jack server.
I think the final message can be fixed by starting the Jack server, however I can't fix the
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
errors
Anyone know how?
The default fluidsynth settings apparently are not appropriate for the Raspberry Pi.
Change the audio driver settings so that uses alsa instead of jack.
If you don't know how to do this in Python, start fluidsynth manually from the command line, and tell your Python program to output to fluidsynth's port.