I am trying to post a question and I can't because I always get this error:
"Your post appears to contain code that is not properly formatted as code"
Even if I can see on the preview that all code is clearly identified, that I used Ctrl + K to format it.
I also tried with
code here
and on the preview everything appears correctly.
But I still get this error and I can't post my question...
How can I get rid of this?
Here is my question:
Hi,
I have some problem using pyaudio.
I am working on ubuntu 18.04 using python 3.6.7, pyaudio version 0.2.11
and the following dependencies : libportaudiocpp0 portaudio19-dev libportaudio2-dev
basically I am running this:
<pre><code>```python
import pyaudio
import wave
CHUNK = 2048*50
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 3
WAVE_OUTPUT_FILENAME = "test.wav"
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0,i).get('maxInputChannels')) > 0:
print("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name'))
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK, input_device_index=0)
print("* recording")
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
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()
</code></pre>
a .wav file is produced but it doesn't contain any sound.
I know my microphone (the one included in the laptop is working (I can skype for example).
here is the output of the script:
>ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
>
>ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel >map
>
>ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
>
>Input Device id 0 - HDA Intel PCH: ALC3228 Analog (hw:0,0)
>
>Input Device id 4 - sysdefault
>
>Input Device id 5 - pulse
>
>Input Device id 6 - default
>
>* recording
>
>* done recording
<pre>
and<code>
wrappers, use the ones provided by SO (4 space indentation or wrapping with triple backticks (```), also it looks like the last bit of your question should be formatted as code (the output), that may help<pre><code>
tags, and add the closing ``` to the code-block. An while you are at it, remove the "Hi,", salutations are not considered noise and do not belong in posts. Good luck!