如何将Seewave频谱图转换为WAV文件 [英] How to convert a seewave spectrogram into a wav file

查看:80
本文介绍了如何将Seewave频谱图转换为WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想操纵一个 seewave 音频频谱图,然后将其转换回一个 .wav 文件.一个简单的例子

I would like to manipulate a seewave audio spectrogram and then convert it back to a .wav file. A quick example

library(tuneR)
library(seewave)

data(tico)
#generate spectrogram with phase information
spec_tico=spectro(tico,plot=FALSE,complex=TRUE,norm=FALSE,dB=NULL)
#manipulate spectrogram
spec_tico_new=dostuff(spec_tico)
#convert back into Wave object - but there is no function spectr2Wave!
tico_new=spectr2Wave(spec_tico_new,...)

seewave 文档中,我找不到与 spectr2Wave 接近的任何东西.

I haven't been able to find anything close to spectr2Wave in the seewave documentation.

你们是否知道如何将其转换回而无需深入研究 wav 文件规格并手动进行操作的方法?谢谢!

Do you guys know a way how to convert it back without digging into the wav file specs and doing it manually? Thank you!

推荐答案

原来是相对简单的!我缺少的重要关键字是短时傅立叶变换"-这基本上就是 seewave :: spectro 的功能.在对"短时傅立叶变换"进行谷歌搜索之后,出现了 seewave 函数 istft .

Turned out to be relatively simple! The important keyword that I was missing is "short-time Fourier transformation" - that is what seewave::spectro basically does. After googling for "inverse short-time Fourier transformation" the seewave function istft showed up.

library(tuneR)
library(seewave)

data(tico)
#generate spectrogram with phase information
spec_tico=spectro(tico,plot=FALSE,complex=TRUE,norm=FALSE,dB=NULL,ovlp=50)
#convert back into Wave object
tico_new=istft(spec_tico$amp,f=tico@samp.rate,ovlp=50,wl=512,output = "Wave")

现在享受Capo Zonotrichia capensis(*)的声音

Now enjoy the sound of Zonotrichia capensis(*)

#play on Windows
play(tico_new)
#play on Linux with vlc (or any other player ...)
play(tico_new,player="cvlc")
#on Linux you have to kill the two vlc processES afterwards!

(*)是执行 play 命令时可以听到的鸟.:)

(*) that's the bird that you can hear if you execute the play command. :)

这篇关于如何将Seewave频谱图转换为WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆