I'm dealing with Speech compression using CELP.

1 次查看(过去 30 天)
I implemented the code I got from this link https://www.mathworks.com/matlabcentral/fileexchange/39038-celp-codec. There were a few errors but I resolved them. My only problem is that after running the code, it does not play the audio file. I want to watch the original first and then the encoded audio file. What should I do?

采纳的回答

Hassaan
Hassaan 2024-1-15
编辑:Hassaan 2024-1-15
% Read the original audio file
[originalAudio, fs] = audioread('path_to_your_original_audio_file.wav');
% Play the original audio file
sound(originalAudio, fs);
pause(length(originalAudio)/fs); % Wait for the original to finish
% Assuming you have the CELP encoding and decoding functions
encodedAudio = celp_encode(originalAudio, fs); % This function should encode the audio
decodedAudio = celp_decode(encodedAudio, fs); % This function should decode the audio
% Play the encoded and then decoded audio file
sound(decodedAudio, fs);
% Wait for the decoded to finish, if necessary
% pause(length(decodedAudio)/fs); % Uncomment if needed
% If you do not want to wait for the entire audio to play before moving on with the code,
% you can use the audioplayer function to have more control over playback:
% player = audioplayer(decodedAudio, fs); % Uncomment if needed
% play(player); % This plays the sound asynchronously. Uncomment if needed
Make sure to replace `'path_to_your_original_audio_file.wav'` with the actual path to your audio file. If `celp_encode` and `celp_decode` are not the actual names of the functions used for encoding and decoding in the CELP codec you implemented, replace them with the correct function names.
If the playback doesn't start or you encounter errors, ensure that:
- Your audio device is functioning correctly.
- MATLAB's volume is not muted or too low.
- The encoded and decoded audio data is in the correct format for playback.
Also, be aware that the `sound` function immediately starts playback in MATLAB and will block until it's complete, hence the use of `pause`. The `audioplayer` function, on the other hand, allows for asynchronous playback control.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  4 个评论
Mert Sari
Mert Sari 2024-1-15
After what you wrote, I solved the problem with my own comment, thank you!
Stephen23
Stephen23 2024-1-15
"I mean to say it blocks and once the playback completes then it continues the below statements."
That is incorrect.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by