How to implement the Huffman codes to voice signal?

1 回表示 (過去 30 日間)
aaa bbb
aaa bbb 2014 年 1 月 10 日
コメント済み: Parth Patel 2022 年 11 月 29 日
Hi,
I have a voice signal that I have quantized and now I have to employ Huffman coding to the quantized samples. I have tried to implement the "huffmanenco" but I keep getting the same error message, I would be glad if someone can help me out.
Here are the codes that I have written:
...
%Quantization
partition=[-0.2:0.04:0.2];
codebook=[-.24:0.04:-0.2];
[index,quants] = quantiz(myRecording,partition,codebook)
plot(quants)
%Probability distribution
prob_y = arrayfun(@(x)length(find(quants==x)), unique(quants)) / length(quants)
%Huffman Encoding
symbols = [1:17]; % Distinct symbols that data source can produce
p = prob_y; % Probability distribution
[dict,avglen] = huffmandict(symbols,p); % Create dictionary.
comp = huffmanenco(quants,dict);
Error: The Huffman dictionary provided does not have the codes for all the input signals.
Thanks in advance

回答 (2 件)

Walter Roberson
Walter Roberson 2014 年 1 月 11 日
quants is the floating point values, the codebook indexed by the appropriate index. If you want the symbol range to be 1:17 then you want to be passing in "index" not quants.

aaa bbb
aaa bbb 2014 年 1 月 11 日
Thanks a lot
  1 件のコメント
Parth Patel
Parth Patel 2022 年 11 月 29 日
if u got the output now , kindly share the whole code for that

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSource Coding についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by