resample audio signal

194 views
Skip to first unread message

Arkadi Gurevich

unread,
Mar 30, 2018, 5:26:02 AM3/30/18
to kaldi-help
Hey
I am trying to change the sample rate of a file represented by 16 bits and sampled at 22050 HZ to a sample rate of 16000 Hz by the "LinearResample" object.
I try to work with chunks but I get a bad result.
I enclose my code (this is a general description of the code) and a picture of the result I get.
I looked at the Unit test of LinearResample and I can not figure out where my error is.
I would be happy if anyone could help.
Cheers


code_question.txt
Screenshot from 2018-03-30 02-21-04.png
Message has been deleted

Arkadi Gurevich

unread,
Mar 30, 2018, 5:30:05 AM3/30/18
to kaldi-help
I forgot to note that the audio_in array is a char array, containing the samples I read from the PCM file.

Daniel Povey

unread,
Mar 30, 2018, 2:13:47 PM3/30/18
to kaldi-help
You don't indicate what you feel is bad about the result you get.  It looks fine to me.  Maybe the original signal looked like that too.


--
Go to http://kaldi-asr.org/forums.html find out how to join
---
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.
To post to this group, send email to kaldi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kaldi-help/77aed6fc-a8b2-4882-8bd6-91ca72160a9a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Arkadi Gurevich

unread,
Mar 30, 2018, 4:34:00 PM3/30/18
to kaldi-help
What bothers ne with the result is that there is a metallic noise throughout the trail.
I also wanted to know if there is something wrong with my code.
Thank you

Daniel Povey

unread,
Mar 30, 2018, 4:37:32 PM3/30/18
to kaldi-help
I don't know how you thought I could see a metallic noise in a screenshot.  Maybe that metallic noise was there in the original audio.
The code you included didn't actually have the core parts of your code in it, just some wrapper code.  I couldn't see any problem there.

Dan


--
Go to http://kaldi-asr.org/forums.html find out how to join
---
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.
To post to this group, send email to kaldi...@googlegroups.com.

Arkadi Gurevich

unread,
Mar 30, 2018, 5:13:35 PM3/30/18
to kaldi-help
Thank you for the fast response.
Actually what I want to do is:
1. Read audio file into char array in chunks.
2. Convert the bytes to samples and construct BaseFloat vector for each chunk
3. Resample
4. Convert the BaseFloat vector of resampled audio back to char array.

I have difficulty in stages 2 and 4.
Can you explain how to do it correctly?
(My file is 16Bit com samples 22050Hz)
or provide a link with Manuel?

On Friday, March 30, 2018 at 11:37:32 PM UTC+3, Dan Povey wrote:
> I don't know how you thought I could see a metallic noise in a screenshot.  Maybe that metallic noise was there in the original audio.
> The code you included didn't actually have the core parts of your code in it, just some wrapper code.  I couldn't see any problem there.
>
>
>
> Dan
>
>
>
>
>
> On Fri, Mar 30, 2018 at 4:34 PM, Arkadi Gurevich <ark...@onvego.com> wrote:
> What bothers ne with the result is that there is a metallic noise throughout the trail.
>
> I also wanted to know if there is something wrong with my code.
>
> Thank you
>
>
>
> --
>
> Go to http://kaldi-asr.org/forums.html find out how to join
>
> ---
>
> You received this message because you are subscribed to the Google Groups "kaldi-help" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+...@googlegroups.com.

Daniel Povey

unread,
Mar 30, 2018, 5:42:16 PM3/30/18
to kaldi-help

Thank you for the fast response.
Actually what I want to do is:
1. Read audio file into char array in chunks.
2. Convert the bytes to samples and construct BaseFloat vector for each chunk
3. Resample
4. Convert the BaseFloat vector of resampled audio back to char array.

I have difficulty in stages 2 and 4.
Can you explain how to do it correctly?
(My file is 16Bit com samples 22050Hz)
or provide a link with Manuel?

I suspect your actual problem is how you are invoking the resampling code.  The reason it's an object, not a function call, is that it needs to retain state between chunks.  You need to use the same object.  But if you are creating a new object for individual chunks and then appending them together, you'll get strange edge effects.

The way you are doing the conversion to 16bit looks plausible except for some issues in your C code like double allocation, but that's just standard "C" and anyone can help you with that.


Dan
 

On Friday, March 30, 2018 at 11:37:32 PM UTC+3, Dan Povey wrote:
> I don't know how you thought I could see a metallic noise in a screenshot.  Maybe that metallic noise was there in the original audio.
> The code you included didn't actually have the core parts of your code in it, just some wrapper code.  I couldn't see any problem there.
>
>
>
> Dan
>
>
>
>
>
> On Fri, Mar 30, 2018 at 4:34 PM, Arkadi Gurevich <ark...@onvego.com> wrote:
> What bothers ne with the result is that there is a metallic noise throughout the trail.
>
> I also wanted to know if there is something wrong with my code.
>
> Thank you
>
>
>
> --
>
> Go to http://kaldi-asr.org/forums.html find out how to join
>
> ---
>
> You received this message because you are subscribed to the Google Groups "kaldi-help" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+...@googlegroups.com.
>
> To post to this group, send email to kaldi...@googlegroups.com.
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/kaldi-help/e1f4a655-f005-4895-be39-83d53eae2834%40googlegroups.com.
>
>
>
> For more options, visit https://groups.google.com/d/optout.

--
Go to http://kaldi-asr.org/forums.html find out how to join
---
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.

To post to this group, send email to kaldi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages