I'm having trouble visualizing my .wav file
There are total of 5 signals combined together in my .wav file
Lets assume the .wav file is lucky.wav
##My syntax in R
library(tuneR)
library(seewave)
audio_file<-readWave("luckky.wav")
length(sdata)
[1] 3595680
How do i view all the Signals in lucky.wav file?
I've tried length=hdr$nSignals but I got an error.
Please help me in R or in Python. Thank you
What do you mean? you want to see each wave individually? Like if you have a music file you want to see waves from vocal, drum, and piano? If that what you want to do, you cant do that. When you combine 2 signals, the frequency of that 2 signals combined becomes 1 new signal. You can never see the source signal again
Related
I have some .wma file which I am trying to merge into a single one...
I started with python reading files in bytes and writing them into a new one, just as I tried the cmd command copy /b file1.wma + file2.wma + else.wma total.wma
all came up with the same result: my total file was as large in byte as real total of my segments, but when I try to open the file it plays the first segment both in length(time) and content -meaning that I have a 15 MB 10 second voice :-))
I tried to do that with different .wma files but each time it is the first one in length and content and total of them in size.
My assumption is that probably some were my .wma data frame (maybe in file header) there is a data about length of current file, so that after merging the file when the player attempts to play the file reads that data about time and stops after the time. or some like that.
so I need to edit those data frame or header (if even exist) in a way that matches my final output or just simply ignore that.
but I don't know whether it is right or how I can do that
.wma file sample: https://github.com/Fsunroo/PowerPointVoiceExtract (media1.wma and media2.wma for example)
note: there is no such problem with web applications that join songs (maybe they do editing header??!)
Note2: it is a part of my code witch extract voice from a power point file.
I solved the problem by using moviepy.editor
the corrected project is accessible at: https://github.com/Fsunroo/PowerPointVoiceExtract
I was working with audio processing but got stuck. I have a video file which first I converted to .wav file. Actually I need to extract only the vocal part. What I did is I am able to remove the vocal part and only the background sound. That means I have two file now one the main file another only the music file i.e. Karoake file. Both the file sample rate is same. What I am planning to do that to compare the file whenever the main file and karoake file at exactly the same time will give zero if both are same. In the process I can extract the vocal parts only. I am new to octave and matlab. I am attaching my till date work.
[wave,fs]=wavread('music.wav');
[wave1,fs1]=wavread('sound.wav');
t=0:1/fs:(length(wave)-1)/fs;
t1=0:1/fs1:(length(wave1)-1)/fs1;
for x=0:length(wave)
if (wave{x}==wave1{x})
wave2{x}=wave{x}-wave1{x};
else
endif
endfor
for loop is showing an error.
EDIT: OK the question I asked was not actually the question. What I want is that to extract the vocal part only of an audio file.
In Matlab (or Octave) you can only index matrix with "()". Moreover the start index in Matlab is 1, not 0 like in C or Java. So I think your code must be correct by:
for x=1:length(wave)
if (wave(x)==wave1(x))
wave2(x)=wave(x)-wave1(x);
end
You can also remove the for instruction by using some arrays multiplications:
wave2 = (wave - wave1).*(wave1==wave);
I am trying to read an audio file of type .au in python. I would like to have a vector with the amplitudes of the waveform contained in the audio file much in the same way as I can read *.wav files with scipy:
import scipy.io.wavfile as wav
rate,sig=wav.read('filename')
There is a built-in module for opening *.au files, i.e. sunau but I did not manage getting the amplitude vector using it. If I use the function 'sunau.Au_read' I can open a file but I am not able to extract the numbers I want but I can only do something like:
In [44]: f=sunau.Au_read('sound.au')
In [45]: f.readframes(10)
Out[45]: '\x0c\x02\x0c\x02,\x02L\x02\x14\x01,\x02,\x02\xec\x01L\x02\x04\x01'
I have no idea what to do with that string... In Matlab there is the function 'auread', is there an equivalent in Python?
Any help is greatly appreciated! :)
I am looking for a way that I can combine multiple wave files into one wave file using python and run it on linux. I don't want to use any add on other than the default shell command line and default python modules.
For example, if I have a.wav and b.wav. I want to create a c.wav which start with the content from a.wav then b.wav.
I've found wave module, that I can open a wave file and write into a new file. Since i'm really new in this audio world. I still can't figure out how to do it. Below is my code
import struct, wave
waveFileA = wave.open('./a.wav', 'r')
waveFileB = wave.open('./b.wav', 'r')
waveFileC = wave.open('./c.wav', 'w')
lengthA = waveFileA.getnframes()
for i in range(0,lengthA):
waveFileC.writeframes(waveFileA.readframes(1))
lengthB = waveFileB.getnframes()
for i in range(0,lengthB):
waveFileC.writeframes(waveFileB.readframes(1))
waveFileA.close()
waveFileB.close()
waveFileC.close()
When i run this code, I got this error:
wave.Error: # channels not specified
Please can any one help me?
You need to set the number of channels, sample width, and frame rate:
waveFileC.setnchannels(waveFileA.getnchannels())
waveFileC.setsampwidth(waveFileA.getsampwidth())
waveFileC.setframerate(waveFileA.getframerate())
If you want to handle a.wav and b.wav having different settings, you'll want to use something like pysox to convert them to the same settings, or for nchannels and sampwidth you may be able to tough through it yourself.
Looks like you need to call n=waveFileA.getnchannels() to find out how many channels the first input file uses, likewise for waveFileB, then you'll need to use waveFileC.setnchannels(n) to tell it how many channels to put in the outgoing file. I don't know how it will handle input files with different numbers of channels...
Here is the answer I am looking for
How to join two wav files using python?
(look for a thread by Tom 10)
It's in another thread. some one already solved this problem.
I'm trying to make a siren sound in python with beeps, but had no success..
I'm trying something like
winsound.Beep(700,500)
winsound.Beep(710,500)
winsound.Beep(720,500)
...
It's a better way to do it? And play it?
Without external files...
Thx
Record a high quality siren as a WAV file (Audacity is a nice tool for this task, and might even provide the right mix of sound generators for this) and use PlaySound.
winsound.PlaySound('siren.wav', winsound.SND_FILENAME)
You could also bundle it into the script as a string to avoid having a separate file:
siren = base64.b64decode('''
<base64-encoded data>
''')
winsound.PlaySound(siren, winsound.SND_MEMORY)
To create the data for siren, run the WAV file through a base64 encoder (e.g., here is a basic command-line tool — the download includes a win32 exe) and paste the output into the siren string. Base64 isn't a requirement, by the way; it's just a convenient way to embed binary data into a Python source file.
I remember using something similar on QBASIC when I was still a kid:
DO
FOR n = -180 TO 180 STEP .1
f = 440 + 50 * SIN(n)
SOUND f, 1
NEXT
LOOP
SOUND f, 1 should be the same thing as winsound.Beep, with pitch and duration. It used to work great but since I took the snippet here I'm not sure I did exactly this way.
It's just to give you the idea..