Effacer les filtres
Effacer les filtres

I'm dealing with Speech compression using CELP.

3 vues (au cours des 30 derniers jours)
Mert Sari
Mert Sari le 15 Jan 2024
Commenté : Stephen23 le 15 Jan 2024
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?

Réponse acceptée

Hassaan
Hassaan le 15 Jan 2024
Modifié(e) : Hassaan le 15 Jan 2024
% 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 commentaires
Mert Sari
Mert Sari le 15 Jan 2024
After what you wrote, I solved the problem with my own comment, thank you!
Stephen23
Stephen23 le 15 Jan 2024
"I mean to say it blocks and once the playback completes then it continues the below statements."
That is incorrect.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by