mmorise / World

A high-quality speech analysis, manipulation and synthesis system
http://www.kisc.meiji.ac.jp/~mmorise/world/english
Other
1.17k stars 251 forks source link

Harvest will crash when analysis audio which close to silence #59

Closed yamachu closed 6 years ago

yamachu commented 6 years ago

I use Harvest to get f0 from the microphone by pipeline processing, for realtime-analysis. Audio length to analyze is about 150~200 msec in one proc. There is no problem if you always say something, but it will crash when I say nothing.

And I tried it as follows. ./f0analysis sil_file_about_1sec.wav

ref?: #43

yamachu commented 6 years ago

It will crash here https://github.com/mmorise/World/blob/master/src/harvest.cpp#L944

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001000187a5 f0analysis`(anonymous namespace)::MergeF0(multi_channel_f0=0x0000000100600000, boundary_list=0x0000000102005400, number_of_channels=0, f0_length=687, f0_candidates=0x000000010106c600, f0_scores=0x000000010106dc00, number_of_candidates=35, merged_f0=0x0000000102003e00) at harvest.cpp:945
   942    MakeSortedOrder(boundary_list, number_of_channels, order);
   943
   944    for (int i = 0; i < f0_length; ++i)
-> 945      merged_f0[i] = multi_channel_f0[0][i];
   946
   947    for (int i = 1; i < number_of_channels; ++i)
   948      if (boundary_list[order[i] * 2] - boundary_list[1] > 0) {

Stack trace is ...

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001000187a5 f0analysis`(anonymous namespace)::MergeF0(multi_channel_f0=0x0000000100600000, boundary_list=0x0000000102005400, number_of_channels=0, f0_length=687, f0_candidates=0x000000010106c600, f0_scores=0x000000010106dc00, number_of_candidates=35, merged_f0=0x0000000102003e00) at harvest.cpp:945
    frame #1: 0x0000000100017f9c f0analysis`(anonymous namespace)::FixStep3(f0_step2=0x0000000102002800, f0_length=687, number_of_candidates=35, f0_candidates=0x000000010106c600, allowed_range=0.17999999999999999, f0_scores=0x000000010106dc00, f0_step3=0x0000000102003e00) at harvest.cpp:987
    frame #2: 0x000000010001461e f0analysis`(anonymous namespace)::FixF0Contour(f0_candidates=0x000000010106c600, f0_scores=0x000000010106dc00, f0_length=687, number_of_candidates=35, best_f0_contour=0x0000000102001200) at harvest.cpp:1037
    frame #3: 0x0000000100013bfd f0analysis`(anonymous namespace)::HarvestGeneralBody(x=0x0000000101001000, x_length=10982, fs=16000, frame_period=1, f0_floor=71, f0_ceil=800, channels_in_octave=40, speed=2, temporal_positions=0x0000000101018a00, f0=0x0000000101017400) at harvest.cpp:1199
    frame #4: 0x00000001000135b0 f0analysis`::Harvest(x=0x0000000101001000, x_length=10982, fs=16000, option=0x00007fff5fbff270, temporal_positions=0x0000000101016e00, f0=0x0000000101016800) at harvest.cpp:1240
    frame #5: 0x00000001000016b5 f0analysis`main + 405
    frame #6: 0x00007fffc772d235 libdyld.dylib`start + 1

I used this file. https://drive.google.com/file/d/1mtf5NK2x-mBYwI_t_Oc9-FXj5OQff5r3/view?usp=sharing

Channels       : 1
Sample Rate    : 16000
Precision      : 16-bit
Duration       : 00:00:00.69 = 10982 samples ~ 51.4781 CDDA sectors
File Size      : 22.0k
Bit Rate       : 257k
Sample Encoding: 16-bit Signed Integer PCM

In #56

You can solve this problem by adding a extremely small noise.

How much noise should I add?

mmorise commented 6 years ago

Thank you for your comment.

I checked the function and confirmed the error you pointed out. We can overcome this error by modifying the line 987.

  MergeF0(multi_channel_f0, boundary_list, number_of_channels, f0_length,
      f0_candidates, f0_scores, number_of_candidates, f0_step3);

This is modified as follows.

  if (number_of_channels != 0)
    MergeF0(multi_channel_f0, boundary_list, number_of_channels, f0_length,
        f0_candidates, f0_scores, number_of_candidates, f0_step3);

However, since I don't believe that this is the best solution yet, I don't reflect this modification. After several validations, I will push the debugged program.

yamachu commented 6 years ago

Thank you for your reply.

I tried this patch https://github.com/yamachu/World/commit/aa9b1f03d27510ff950075bf2fcf110b91822ac5 as you suggested. And then it no longer crashes in my use case. I'm looking forward to the debugged program.