i've tested, now you can too

This commit is contained in:
Brian West
2012-12-20 20:08:42 -06:00
parent d3fcfa8245
commit d67b96af8a
94 changed files with 25305 additions and 2005 deletions

View File

@@ -23,15 +23,15 @@
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#define P 10 /* LP order */
#define LSP_DELTA1 0.05 /* grid spacing for LSP root searches */
#define P 12 /* LP order */
#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */
#define NW 279 /* frame size in samples */
#define N 80 /* frame to frame shift */
#define THRESH 40.0 /* threshold energy/sample for frame inclusion */
#define PI 3.141592654 /* mathematical constant */
#include <stdio.h>
#include <stdlib.h>
@@ -61,19 +61,22 @@ int main(int argc, char *argv[]) {
float Sn[NW]; /* float input speech samples */
float ak[P+1]; /* LPCs for current frame */
float lsp[P]; /* LSPs for current frame */
float lsp_prev[P]; /* LSPs for previous frame */
float E; /* frame energy */
long f; /* number of frames */
long af; /* number frames with "active" speech */
float Eres; /* LPC residual energy */
int i;
int roots;
int unstables;
int lspd;
int lspd, log, lspdt;
float diff;
/* Initialise ------------------------------------------------------*/
if (argc < 3) {
printf("usage: gentest RawFile LSPTextFile [--lspd]\n");
exit(0);
printf("usage: %s RawFile LSPTextFile [--lspd] [--log] [--lspdt] \n", argv[0]);
exit(1);
}
/* Open files */
@@ -91,13 +94,15 @@ int main(int argc, char *argv[]) {
}
lspd = switch_present("--lspd", argc, argv);
log = switch_present("--log", argc, argv);
lspdt = switch_present("--lspdt", argc, argv);
for(i=0; i<NW; i++)
Sn[i] = 0.0;
/* Read SPC file, and determine aks[] for each frame ------------------*/
af = 0;
f = af = 0;
unstables = 0;
while(fread(buf,sizeof(short),N,fspc) == N) {
@@ -117,30 +122,59 @@ int main(int argc, char *argv[]) {
/* If energy high enough, include this frame */
f++;
if (E > THRESH) {
af++;
printf("Active Frame: %ld unstables: %d\n",af, unstables);
find_aks(Sn, ak, NW, P, &Eres);
roots = lpc_to_lsp(&ak[1], P , lsp, 5, LSP_DELTA1);
roots = lpc_to_lsp(ak, P , lsp, 5, LSP_DELTA1);
if (roots == P) {
if (lspd) {
fprintf(flsp,"%f ",lsp[0]);
for(i=1; i<P; i++)
fprintf(flsp,"%f ",lsp[i]-lsp[i-1]);
if (log) {
fprintf(flsp,"%f ",log10(lsp[0]));
for(i=1; i<P; i++) {
diff = lsp[i]-lsp[i-1];
if (diff < (PI/4000.0)*25.0) diff = (PI/4000.0)*25.0;
fprintf(flsp,"%f ",log10(diff));
}
}
else {
fprintf(flsp,"%f ",lsp[0]);
for(i=1; i<P; i++)
fprintf(flsp,"%f ",lsp[i]-lsp[i-1]);
}
fprintf(flsp,"\n");
}
else if (lspdt) {
for(i=0; i<P; i++)
fprintf(flsp,"%f ",lsp[i]-lsp_prev[i]);
fprintf(flsp,"\n");
}
else {
for(i=0; i<P; i++)
fprintf(flsp,"%f ",lsp[i]);
fprintf(flsp,"\n");
}
if (log) {
for(i=0; i<P; i++)
fprintf(flsp,"%f ",log10(lsp[i]));
fprintf(flsp,"\n");
}
else {
for(i=0; i<P; i++)
fprintf(flsp,"%f ",lsp[i]);
fprintf(flsp,"\n");
}
}
memcpy(lsp_prev, lsp, sizeof(lsp));
}
else
unstables++;
}
}
printf("%3.2f %% active frames\n", 100.0*(float)af/f);
fclose(fspc);
fclose(flsp);