Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I WANT TO PUT THIS:
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include "iniparser.h"
- /* compile this with
- * gcc -o configtest configtest.c -I/usr/lib/ -liniparser
- */
- int main(int argc, char * argv[])
- {
- dictionary * ini ;
- char * ini_name ;
- if (argc<2) {
- ini_name = "parser.conf";
- } else {
- ini_name = argv[1] ;
- }
- ini = iniparser_load(ini_name);
- char * s;
- s = iniparser_getstring(ini, "commandlineargs:dict", NULL);
- char* dict = s;
- printf(dict);
- /* not from fatz: printf("%s is a %s", "jimbo", "humpback"); to print jimbo is a humpback */
- s = iniparser_getstring(ini, "commandlineargs:hmm", NULL);
- char* hmm = s;
- printf(hmm);
- iniparser_freedict(ini);
- return 0 ;
- }
- IN THIS:
- #include <pocketsphinx.h>
- /* compile this with
- * $ gcc -o hellow hello_ps.c -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx -I/usr/local/include -L/usr/local/lib -lpocketsphinx -lsphinxbase -lsphinxad -lm -llibiconv
- */
- int
- main(int argc, char *argv[])
- {
- ps_decoder_t *ps;
- cmd_ln_t *config;
- FILE *fh;
- char const *hyp, *uttid;
- int16 buf[512];
- int rv;
- int32 score;
- /* going to try and read a config file
- FILE *configfile;
- configfile = fopen("decode.conf","r");
- */
- /* below are the command line args */
- config = cmd_ln_init(NULL, ps_args(), TRUE,
- "-hmm", "/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k",
- /* this is our custom lm and dic */
- "-lm", "/usr/local/share/pocketsphinx/model/lm/en/0172.lm",
- "-dict", "/usr/local/share/pocketsphinx/model/lm/en/0172.dic", NULL);
- if (config == NULL)
- return 1;
- ps = ps_init(config);
- if (ps == NULL)
- return 1;
- fh = fopen("/home/nobaboon/chicagoscanner/drops from laptop/1-6-2011-133311-testtranscribe/1-6-2011-12383.wav", "rb");
- if (fh == NULL) {
- perror("Failed to open 2324.wav");
- return 1;
- }
- rv = ps_decode_raw(ps, fh, "1-6-2011-133311", -1);
- if (rv < 0)
- return 1;
- hyp = ps_get_hyp(ps, &score, &uttid);
- if (hyp == NULL)
- return 1;
- printf("Recognized: %s\n", hyp);
- fseek(fh, 0, SEEK_SET);
- rv = ps_start_utt(ps, "1-6-2011-133311");
- if (rv < 0)
- return 1;
- while (!feof(fh)) {
- size_t nsamp;
- nsamp = fread(buf, 2, 5, fh);
- rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
- }
- rv = ps_end_utt(ps);
- if (rv < 0)
- return 1;
- hyp = ps_get_hyp(ps, &score, &uttid);
- if (hyp == NULL)
- return 1;
- /* printf("Recognized: %s\n", hyp); */
- printf("Recognized: %s with prob %d\n", hyp, ps_get_prob (ps, NULL));
- fclose(fh);
- ps_free(ps);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement