- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
I'm dealing with Speech compression using CELP.
2 次查看(过去 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?
0 个评论
采纳的回答
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
Feel free to contact me.
4 个评论
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 Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!