필터 지우기
필터 지우기

I'm dealing with Speech compression using CELP.

조회 수: 3 (최근 30일)
Mert Sari
Mert Sari 2024년 1월 15일
댓글: Stephen23 2024년 1월 15일
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에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by