7

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
7
  • I don't have any images in my post so I am not sure :Images being interpreted as incorrectly formatted code is being a good link
    – p.deman
    Commented Aug 7, 2019 at 12:18
  • 2
    If none of the duplicates help at all then you'd need to provide your question body here because without knowing the body of the question there's no way for us to know what's wrong with it Commented Aug 7, 2019 at 12:20
  • 2
    Firstly, get rid of the <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 Commented Aug 7, 2019 at 12:25
  • 2
    It seems you were trying to use fenced code blocks, you have ````python` at the beginning of the block. As Nick said, remove the <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!
    – yivi
    Commented Aug 7, 2019 at 12:28
  • it seems that the problem was the output. but it's really strange to have an output formatted as code. Is there a way to not format it as code but as blockquotes ?
    – p.deman
    Commented Aug 7, 2019 at 12:28
  • 1
    You're probably best putting it in blockquotes AND codeblocks, as the formatting for codeblocks is often better for code output than just as text Commented Aug 7, 2019 at 12:29
  • 1
    @PeterMortensen you probably shouldn't edit the contents of the Markdown in a post reporting a Markdown bug
    – Ryan M Mod
    Commented Aug 2, 2023 at 13:03

0

Browse other questions tagged .