Record voice on Virtual Machine, which lacks some drivers - virtual-machine

From this source code
import pyaudio
import wave
import os
CHUNK = 1024
FORMAT = pyaudio.paInt16 #paInt8
CHANNELS = 2
RATE = 44100 #sample rate
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK) #buffer
print("* recording")
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data) # 2 bytes(16 bits) per channel
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()
# Oben an audio file
#WAVE_OUTPUT_FILENAME.open()
When I am using pyaudio on my local computer It works fine,
But when I use the similar code in Virtual Machine It gives me the following error:
azureuser#sonicplus:~/myapp/static/css$ python VoiceRecorder.py
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM dmix
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
* recording
* done recording
It has no sound. I am new to pyaudio,
Any help will be appreciated.

Related

How to pass "none" to -audioval when running qemu-system-arm on Ubuntu WSL?

I'm trying to run qemu-system-arm Versatilepb emulator with the following command:
qemu-system-arm -M versatilepb -m 128M -kernel t.bin -serial mon:stdio
but whenever I do that, I get an error that my ALSA lib isn't installed:
Unable to init server: Could not connect: Connection refused
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `lm4549.out'
qemu-system-arm: could not load kernel 't.bin'
So I've read that I need to either install ALSA, PA, OSS, or some other form of audio drivers if I want to emulate that specific board. I also saw that I can ignore those errors if I purposely set the audio driver to be none, and that's what I tried doing by trying out the following:
qemu-system-arm -M versatilepb -m 128M -kernel t.bin -serial mon:stdiocode -audiodev none,id=none
that returns this:
audio: Device lm4549: audiodev default parameter is deprecated, please specify audiodev=none
I've tried looking around, but there's a handful of email threads pertaining to maintainers of qemu who are familiar with the -audiodev parameter, but none seem to be just running the emulator with "none" as the audio-driver. What am I doing wrong or how would I go fixing this, without having to install one of the above-mentioned audio driver libs?

Target file fails during INSTALL stage with CMake

I have a CMakeLists.txt file that is building a shared lib as en ExternalProject and this lib needs to be installed in a specific location so that it can be picked up by the main project at build time. I am using the following line to perform the install process:
install(FILES $<TARGET_FILE:of_shared> DESTINATION oF/lib)
However, this fails:
Install the project...
-- Install configuration: ""
CMake Error at cmake_install.cmake:31 (FILE):
file INSTALL cannot find
"/Users/me/packages/builds/x86_64/of-0.9.3-osx-release/$<TARGET_FILE:of_shared>".
make[3]: *** [install] Error 1
make[2]: *** [of_shared-prefix/src/of_shared-stamp/of_shared-install] Error 2
make[1]: *** [CMakeFiles/of_shared.dir/all] Error 2
make: *** [all] Error 2
This might be a compatibility bug of some sort, maybe between CMake versions. I am using CMake 2.8.12.
These are the related CMake lines:
add_library(core OBJECT ${OF_SOURCE_FILES})
add_library(of_shared SHARED $<TARGET_OBJECTS:core>)
set_target_properties(of_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set_target_properties(of_shared PROPERTIES OUTPUT_NAME openFrameworks)
target_link_libraries(of_shared ${OF_CORE_FRAMEWORKS} ${OF_ADDON_FRAMEWORKS} ${OF_CORE_LIBS} ${OF_ADDON_LIBS})
install(FILES $<TARGET_FILE:of_shared> DESTINATION oF/lib)
install(FILES libs/fmodex/lib/osx/libfmodex.dylib DESTINATION oF/lib)
install(DIRECTORY libs/glut/lib/osx/GLUT.framework DESTINATION .)
Obviously that bit with the $<TARGET_FILE:of_shared> is failing. Apart from that, everything is working. I can see the shared lib being created.
I have found the solution myself. Instead of using:
install(FILES $<TARGET_FILE:of_shared> DESTINATION openFrameworks/lib)
One should use:
install(TARGETS of_shared LIBRARY DESTINATION openFrameworks/lib)
In that case of_shared is the name of the library.

no rule to process file of type image.png for architecture i386

I.m trying to create Pod for Cocoapods. And during podspec validation got this error:
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/myfiles.png' of type image.png for architecture i386
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/nav_clear_pixel.png' of type image.png for architecture i386
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/nav_pixel.png' of type image.png for architecture i386
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/samplefiles.png' of type image.png for architecture i386
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/myfiles.png' of type image.png for architecture x86_64
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/nav_clear_pixel.png' of type image.png for architecture x86_64
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/nav_pixel.png' of type image.png for architecture x86_64
- NOTE | xcodebuild: warning: no rule to process file 'sequencing-file-selector-api-objc/Pod/ResourceBundle.bundle/samplefiles.png' of type image.png for architecture x86_64
- NOTE | [iOS] xcodebuild: : error: Not enough arguments provided; where is the input document to operate on?
Podspec contains following settings:
s.resource = 'Pod/ResourceBundle.bundle'
s.resources = ['Pod/ResourceBundle.bundle/*.png']
All images are within ResourceBundle.bundle file
How to handle such error? Can't validate podspec.
As I found out the problem was that I did'n specified resources files as a actually Resources (.png, .storyboard, and .xib) while creating CocoaPod.
So I created a Resources folder within the pod and moved all png images, custom storyboard file and xib files.
In podspec file I added following specification:
s.resources = ['Resources/**/*.*']
As a result podspec file was validated successfully and I was able to release the pod.

Building a library refering to a library in a subdirectory using cmake

I'm trying to convert a build using Makefile that currently works for Unix and Windows. I have the following directory layout:
lib1
lib2
lib2 depends on lib1.
In lib1, I create on Unix a .o file using
ld -r obj1.o -o lib1.o'.
And in lib2, I also create a .o file using the lib1.o file created in the lib1 directory using:
ld -r obj2.o ../lib1/lib1.o -o lib2.o
On Windows it is very similar except we are creating a .lib file using the lib command in lib1:
lib -out:lib1.lib obj1.obj
and in lib2:
lib -out:lib2.lib obj2.obj ..\lib1\lib1.lib
Unfortunately, whatever I do, the lib1.o object file never appears when building lib2.o.
My CMakeLists.txt files are in lib1:
project (lib1)
add_library(lib1 obj1.c)
in lib2:
project (lib2)
add_library(lib2 obj2.c)
target_link_libraries(lib2 lib1)
and at the root I have:
project (root)
add_subdirectory(lib1)
add_subdirectory(lib2)
add_dependencies(lib2 lib1)
Is there something I'm missing to achieve this?
Thanks,
Manu

Does OS matter when compiling for iPhone?

I fairly new on iPhone development and I'm currently trying to add some static libraries to my project but I get the "Symbol(s) not found" error.
I've googled the issue and tried different solutions without any luck. The libraries are compiled on a PC and not on a Mac so my questions are:
Do I need to compile the code on a Mac?
What tool(s) do I need to be able to compile them?
I have included the headers to the project. The code I'm trying to link to are written in c and are compiled for ARM GCC 4.2.
I get the following errorcode:
ld warning: in /Users/<>/Playground/Collage/libbaseapi.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/capseng.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/excodecs.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmautorama.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmclearshot.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmexif.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmextencoder.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmfacewarp.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmfxplugin.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmimageenhance.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmimagefusion.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmjpegsqueeze.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmjpegtools.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmphotoart.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmredaway.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmsemc.a, file is not of required architecture
ld warning: in /Users/<>/Playground/Collage/fmspeedview.a, file is not of required architecture
Undefined symbols:
"_caps_destroyBuffer", referenced from:
-[CollageMainView drawRect:] in CollageMainView.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
"_caps_destroyBuffer", referenced from:
-[CollageMainView drawRect:] in CollageMainView.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (1 error)
BR,
Andreas
You can't add custom (compiled) libraries to an iPhone application. You should always include the source code in your project.
You need to either add the header files for your libraries to your project,
or if it's a missing framework, add it to the "frameworks" folder in Xcode.