audio

Real-time microphone audio playback

谁说我不能喝 提交于 2020-05-16 21:51:18
问题 Okay, I've been looking but haven't found a solution. I've managed to get an byte[] output from the mic with AudioFormat(44100.0f, 32, 2, true, true); format. Okay, but now I want to play it back through my headphones to test it. I've read plenty of things, googled, and looked here, on StackOverflow, but I can't find a way to just get my already stored data to be played int the headphones (or actual audio output device). I've read that the common way is to play it from a Clip (and the clip

Can I convert spectrograms generated with librosa back to audio?

 ̄綄美尐妖づ 提交于 2020-05-15 06:38:27
问题 I converted some audio files to spectrograms and saved them to files using the following code: import os from matplotlib import pyplot as plt import librosa import librosa.display import IPython.display as ipd audio_fpath = "./audios/" spectrograms_path = "./spectrograms/" audio_clips = os.listdir(audio_fpath) def generate_spectrogram(x, sr, save_name): X = librosa.stft(x) Xdb = librosa.amplitude_to_db(abs(X)) fig = plt.figure(figsize=(20, 20), dpi=1000, frameon=False) ax = fig.add_axes([0, 0

Hop_Size meaning in aubio

一个人想着一个人 提交于 2020-05-13 14:38:07
问题 I'm trying to use the aubio(https://aubio.org) library for pitch detection. I'm trying to use the API for C and one of the parameters of the new_aubio_pitch function is hop_size . What does hop_size mean and how do you choose one? 回答1: Hop Size should refer to the number of samples in between successive frames. For signal analysis, Hop Size should be less than the frame size, so that frames overlap. In this diagram the Hop Size would be 'Q' and 'K' is the frame size for a signal 's(n)' If

Generating a sine wave sound in python

点点圈 提交于 2020-05-13 14:18:28
问题 I've been trying to generate a sine wave using the following code and playing it thought my speakers, but it sounds horrible. Anyone knows why? It does not sound like a sine wave. dur = int(FS * float(duration) / 1000) for i in range(dur): a = frequency * i * 2 * math.pi / FS y = math.sin(a) outbuf[i] = y * 0.2 p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paFloat32, channels=1, rate=44100, output=True) stream.write(outbuf) stream.stop_stream() stream.close() p.terminate() play_sound(

Generating a sine wave sound in python

你说的曾经没有我的故事 提交于 2020-05-13 14:13:41
问题 I've been trying to generate a sine wave using the following code and playing it thought my speakers, but it sounds horrible. Anyone knows why? It does not sound like a sine wave. dur = int(FS * float(duration) / 1000) for i in range(dur): a = frequency * i * 2 * math.pi / FS y = math.sin(a) outbuf[i] = y * 0.2 p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paFloat32, channels=1, rate=44100, output=True) stream.write(outbuf) stream.stop_stream() stream.close() p.terminate() play_sound(

ffmpeg: flushing output file every chunk

僤鯓⒐⒋嵵緔 提交于 2020-05-13 02:28:12
问题 I'm using ffmpeg to generate a sine tone in real time for 10 seconds. Unfortunately, ffmpeg seems to flush the output file only rarely, every few seconds. I'd like it to flush every 2048 bytes (=2bytes sample width*1024 samples, my custom chunk size). The output of the following script: import os import time import subprocess cmd = 'ffmpeg -y -re -f lavfi -i "sine=frequency=440:duration=10" -blocksize 2048 test.wav' subprocess.Popen(cmd, shell=True) time.sleep(0.1) while True: print(os.path

ffmpeg: flushing output file every chunk

半世苍凉 提交于 2020-05-13 02:28:06
问题 I'm using ffmpeg to generate a sine tone in real time for 10 seconds. Unfortunately, ffmpeg seems to flush the output file only rarely, every few seconds. I'd like it to flush every 2048 bytes (=2bytes sample width*1024 samples, my custom chunk size). The output of the following script: import os import time import subprocess cmd = 'ffmpeg -y -re -f lavfi -i "sine=frequency=440:duration=10" -blocksize 2048 test.wav' subprocess.Popen(cmd, shell=True) time.sleep(0.1) while True: print(os.path

ffmpeg: flushing output file every chunk

倾然丶 夕夏残阳落幕 提交于 2020-05-13 02:26:22
问题 I'm using ffmpeg to generate a sine tone in real time for 10 seconds. Unfortunately, ffmpeg seems to flush the output file only rarely, every few seconds. I'd like it to flush every 2048 bytes (=2bytes sample width*1024 samples, my custom chunk size). The output of the following script: import os import time import subprocess cmd = 'ffmpeg -y -re -f lavfi -i "sine=frequency=440:duration=10" -blocksize 2048 test.wav' subprocess.Popen(cmd, shell=True) time.sleep(0.1) while True: print(os.path

FFMPEG mkv to mp4 conversion lacks audio in HTML5 player

强颜欢笑 提交于 2020-05-11 07:49:26
问题 I used ffmpeg to convert an mkv file to mp4 using this command line: ffmpeg -i input.mkv -c copy file-1.mp4 The resulting mp4 plays fine (video and audio) on Linux Mint's Xplayer . But after uploading file-1, it played with no audio. So I uploaded another mp4 file-2, one I didn't have to convert, and it plays both video and audio without a problem. So whatever's going on with file-1 seems to be with my use of ffmpeg . The player I'm using is called afterglow . But the HTML5 player handles

FFMPEG mkv to mp4 conversion lacks audio in HTML5 player

时光总嘲笑我的痴心妄想 提交于 2020-05-11 07:47:34
问题 I used ffmpeg to convert an mkv file to mp4 using this command line: ffmpeg -i input.mkv -c copy file-1.mp4 The resulting mp4 plays fine (video and audio) on Linux Mint's Xplayer . But after uploading file-1, it played with no audio. So I uploaded another mp4 file-2, one I didn't have to convert, and it plays both video and audio without a problem. So whatever's going on with file-1 seems to be with my use of ffmpeg . The player I'm using is called afterglow . But the HTML5 player handles