Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
krylenko committed Jun 4, 2014
0 parents commit fe51ef6
Show file tree
Hide file tree
Showing 19 changed files with 1,060 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
215 changes: 215 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
28 changes: 28 additions & 0 deletions LPCSR_AddOverlap.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
% LPCSR_AddOverlap Frame overlapping and addition to concatenate complete
% output sample
%
% [s,e,g,pd] = LPCSR_AddOverlap(sout,excit,L,R,s,e,g,pd,n) adds the
% L-length input frames sout and excit to the following existing output
% arrays with R samples of frame offset:
% s: synthesized output array
% e: complete excitation array
% g: complete gain history
% pd: complete pitch period array
%
% When adding sout to the s array, sout is soft-clipped to [-1,1] by tanh.
%
% LPC Speech Recognition Project
% ECE 529 Spring 2014
% Daniel Ford

function [s,e,g,pd] = LPCSR_AddOverlap(s,e,g,pd,sout,excit,b0,pitch,L,R,n)

for b=1:L % add frames w/ R samples overlap
if n==1
s(b) = tanh(sout(b)); % add values w/ soft clipping
e(b) = excit(b); g(b) = b0; pd(b) = pitch;
else
s(n+b) = tanh(s(n+b) + sout(b)); % add values w/ soft clipping
e(n+b) = excit(b); g(n+b) = b0; pd(n+b) = pitch;
end
end
34 changes: 34 additions & 0 deletions LPCSR_Analysis.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
% LPCSR_Analysis Filter coefficient estimation and pitch detection for LPC
% speech coding
%
% [b0,a,pitch,v] = LPCSR_Analysis(in,fs,L,order) returns the numerator
% coefficient b0 (frame gain) and denominator coefficient of an IIR synthesis
% filter estimated from input sample in, as well as the fundamental pitch
% period of the sample, if periodic, and the voiced/unvoiced detection
% parameter V. V = 1 if the sample is periodic and 0 if it is not, in which
% case pitch will also be 0.
%
% The filter coefficients are estimated with Prony's method, while the
% pitch period and voiced/unvoiced detection are computed using
% autocorrelation. The pitch period is limited to periods equivalent to
% frequencies betwee 80 and 350 Hz.
%
% LPC Speech Recognition Project
% ECE 529 Spring 2014
% Daniel Ford

function [b0,a,pitch,v] = LPCSR_Analysis(in,fs,L,order)

% limit pitch range to 80-350 Hz
pmin = int32(fs/350);
pmax = int32(fs/80);

% init arrays
win=hamming(L); % L-length hamming window

% perform LPC analysis
xw=in.*win; % window input w/ hamming
[a,G] = LPCSR_Prony(xw,order,0); % determine coeffs
b0 = sqrt(G); % convert G to b0 coeff
[pitch,v] = LPCSR_Autocorr(xw,pmin,pmax); % determine pitch

75 changes: 75 additions & 0 deletions LPCSR_Autocorr.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
% LPCSR_Autocorr Pitch estimation and voiced/unvoiced detection for an input
% sample
%
% [Tp,V] = LPCSR_Autocorr(X,pitchmin,pitchmax) computes the autocorrelation
% of input sample X to determine whether X is periodic and, if so, estimate
% its fundamental pitch period Tp in samples within the range [pitchmin,
% pitchmax]. If X is periodic, the voiced/unvoiced parameter V will be set
% to 1. If not, both V and Tp will be 0.
%
% LPC Speech Recognition Project
% ECE 529 Spring 2014
% Daniel Ford

function [Tp,V] = LPCSR_Autocorr(X,pitchmin,pitchmax)

kmin = pitchmin;
kmax = pitchmax;
N = length(X);
Rn = zeros(length(X),1);

% measure max value in X
max = X(1);
for i=1:length(X)
if X(i) > max
max = X(i);
end
end
CL = 0.3*max;

% perform clipping
for i=1:length(X)
if X(i) > CL
X(i) = 1;
else
if X(i) < -CL
X(i) = -1;
else
X(i) = 0;
end
end
end

% do autocorrelation
for k=kmin:kmax
for m=1:length(X)-k
Rn(k) = Rn(k) + X(m)*X(m+k);
end
end

% calculate Rn(0)
R0 = 0;
for m=1:length(X)
R0 = R0 + X(m)*X(m);
end

% find max R and delay k
Rmax = Rn(1); kidx = 1;
for k=1:length(Rn)
if Rn(k) > Rmax
Rmax = Rn(k); % save max R
kidx = k + kmin - 1; % save pitch period
end
end

% decide voiced or unvoiced
if Rmax > 0.1*R0 % lower creates more voiced frames
% higher values w/ unfiltered noise are good too
V = 1;
Tp = kidx;
else
V = 0;
Tp = 0;
end

end % function end
Loading

0 comments on commit fe51ef6

Please sign in to comment.