ggerganov commited on
Commit
1434bfe
·
unverified ·
1 Parent(s): 0755fa0

whisper : handle empty mel (#2324)

Browse files
Files changed (1) hide show
  1. src/whisper.cpp +4 -1
src/whisper.cpp CHANGED
@@ -1920,7 +1920,7 @@ static struct ggml_cgraph * whisper_build_graph_conv(
1920
  ggml_set_input(mel_inp);
1921
 
1922
  ggml_tensor * mel;
1923
- {
1924
  const int n_len = int(mel_inp->ne[0]);
1925
  const int out_s = 2 * n_ctx;
1926
  const int i0 = std::min(mel_offset, n_len);
@@ -1937,6 +1937,9 @@ static struct ggml_cgraph * whisper_build_graph_conv(
1937
  } else {
1938
  mel = ggml_cont(ctx0, cur);
1939
  }
 
 
 
1940
  }
1941
 
1942
  ggml_set_name(mel, "mel");
 
1920
  ggml_set_input(mel_inp);
1921
 
1922
  ggml_tensor * mel;
1923
+ if (ggml_nelements(mel_inp) > 0) {
1924
  const int n_len = int(mel_inp->ne[0]);
1925
  const int out_s = 2 * n_ctx;
1926
  const int i0 = std::min(mel_offset, n_len);
 
1937
  } else {
1938
  mel = ggml_cont(ctx0, cur);
1939
  }
1940
+ } else {
1941
+ // empty mel - just create a dummy tensor with the correct size
1942
+ mel = ggml_new_tensor_2d(ctx0, GGML_TYPE_F32, 2*n_ctx, n_mels);
1943
  }
1944
 
1945
  ggml_set_name(mel, "mel");