Browse Source

Expose the CompileMbrola function via a new espeak_ng.h API.

master
Reece H. Dunn 9 years ago
parent
commit
b8378c2667
4 changed files with 68 additions and 12 deletions
  1. 3
    3
      .gitignore
  2. 4
    3
      src/espeakedit.cpp
  3. 53
    0
      src/include/espeak-ng/espeak_ng.h
  4. 8
    6
      src/libespeak-ng/compiledata.c

+ 3
- 3
.gitignore View File

@@ -44,9 +44,9 @@ libespeak-ng.so*
# programs

platforms/*/espeak-phoneme-data
espeak-ng
espeakedit
speak-ng
src/espeak-ng
src/espeakedit
src/speak-ng

# Linux/Source distribution files


+ 4
- 3
src/espeakedit.cpp View File

@@ -33,6 +33,8 @@
#include <locale.h>

#include "speak_lib.h"
#include "espeak_ng.h"

#include "main.h"
#include "speech.h"
#include "options.h"
@@ -63,7 +65,6 @@ extern void DictionarySort(const char *dictname);
extern void init_z();
extern void CompilePhonemeData(void);
extern void CompileSampleRate(void);
extern "C" void CompileMbrola(const char *mbrola_file);
extern void CompileIntonation();
extern void InitSpectrumDisplay();
extern void InitProsodyDisplay();
@@ -157,7 +158,7 @@ if(argc > 1)
fprintf(stderr, "Failed to load default voice\n");
exit(1);
}
CompileMbrola(argv[2]);
espeak_ng_CompileMbrolaVoice(argv[2], stdout);
}
exit(0);
}
@@ -792,7 +793,7 @@ void MyFrame::OnTools(wxCommandEvent& event)
case MENU_COMPILE_MBROLA:
{
wxString filepath = wxFileSelector(_T("Read Mbrola phonemes file"),path_phsource+_T("/mbrola"),_T(""),_T(""),_T("*"),wxOPEN);
CompileMbrola(filepath.mb_str(wxConvLocal));
espeak_ng_CompileMbrolaVoice(filepath.mb_str(wxConvLocal), stdout);
}
break;


+ 53
- 0
src/include/espeak-ng/espeak_ng.h View File

@@ -0,0 +1,53 @@
/* eSpeak NG API.
*
* Copyright (C) 2015 Reece H. Dunn
*
* This file is part of espeak-ng.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ESPEAK_NG_H
#define ESPEAK_NG_H

#ifdef __cplusplus
extern "C"
{
#endif

#ifdef __WIN32__
#define ESPEAK_NG_API __declspec(dllexport)
#else
#define ESPEAK_NG_API
#endif

typedef enum {
/* Success Codes (>= 0) */

ENS_OK = 0,

/* Error Codes (< 0) */

ENE_NOT_FOUND = -1,
ENE_WRITE_FAILED = -2,
} espeak_ng_STATUS;

ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_CompileMbrolaVoice(const char *path, FILE *log);

#ifdef __cplusplus
}
#endif

#endif

+ 8
- 6
src/libespeak-ng/compiledata.c View File

@@ -22,6 +22,7 @@
#include <unistd.h>

#include "speak_lib.h"
#include "espeak_ng.h"

#include "phoneme.h"
#include "speech.h"
@@ -47,7 +48,7 @@ static unsigned int StringToWord(const char *string)
return(word);
}

void CompileMbrola(const char *filepath)
espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
{
char *p;
FILE *f_in;
@@ -70,8 +71,8 @@ void CompileMbrola(const char *filepath)
strcpy(buf,filepath);
if((f_in = fopen(buf,"r")) == NULL)
{
fprintf(stderr, "Can't read: %s\n", filepath);
return;
fprintf(log, "Can't read: %s\n", filepath);
return ENE_NOT_FOUND;
}

while(fgets(buf,sizeof(phoneme),f_in) != NULL)
@@ -116,8 +117,8 @@ void CompileMbrola(const char *filepath)
sprintf(buf,"%s/mbrola_ph/%s_phtrans",path_home,mbrola_voice);
if((f_out = fopen(buf,"wb")) == NULL)
{
fprintf(stderr, "Can't write to: %s\n", buf);
return;
fprintf(log, "Can't write to: %s\n", buf);
return ENE_WRITE_FAILED;
}

data[count].name = 0; // list terminator
@@ -129,5 +130,6 @@ void CompileMbrola(const char *filepath)
Write4Bytes(f_out, *pw);
}
fclose(f_out);
fprintf(stdout, "Mbrola translation file: %d phonemes", count);
fprintf(log, "Mbrola translation file: %s -- %d phonemes\n", buf, count);
return ENS_OK;
}

Loading…
Cancel
Save