Skip to content

Commit

Permalink
Add check for audio sampling rate other than 8k or 16k Hz (#898)
Browse files Browse the repository at this point in the history
* add check for sr other than 8k or 16k

* update error message to mention resampling

* return error status

---------

Co-authored-by: Sayan Shaw <[email protected]>
  • Loading branch information
sayanshaw24 and Sayan Shaw authored Feb 28, 2025
1 parent f63857d commit 5541566
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion shared/api/speech_features.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,13 @@ class Phi4AudioEmbed {

SpeechLibLogMel logmel;
// already checked in Init
logmel.Init(sr_val == 8000? logmel_8k_attrs_: logmel_attrs_);

// Currently we only support 8k and 16k Hz sampling rate.
if (sr_val != 8000 && sr_val != 16000){
return OrtxStatus(kOrtxErrorNotImplemented, "Currently only 8k and 16k Hz sampling rate is supported. Please resample your audio file with unsupported audio sampling rate: " + sr_val);
}

logmel.Init(sr_val == 8000 ? logmel_8k_attrs_: logmel_attrs_);
status = logmel.Compute(stft_norm, ts_logmel);
if (!status.IsOk()) {
return status;
Expand Down

0 comments on commit 5541566

Please sign in to comment.