Browse Source

code cleanup: Add new source file common.h for misc functions.

master
Juho Hiltunen 2 years ago
parent
commit
c4d8976fbc

+ 2
- 0
Makefile.am View File

src/ucd-tools/src/proplist.c \ src/ucd-tools/src/proplist.c \
src/ucd-tools/src/scripts.c \ src/ucd-tools/src/scripts.c \
src/ucd-tools/src/tostring.c \ src/ucd-tools/src/tostring.c \
src/libespeak-ng/common.c \
src/libespeak-ng/compiledata.c \ src/libespeak-ng/compiledata.c \
src/libespeak-ng/compiledict.c \ src/libespeak-ng/compiledict.c \
src/libespeak-ng/compilembrola.c \ src/libespeak-ng/compilembrola.c \
src/libespeak-ng/wavegen.c src/libespeak-ng/wavegen.c


noinst_HEADERS = \ noinst_HEADERS = \
src/libespeak-ng/common.h \
src/libespeak-ng/compiledict.h \ src/libespeak-ng/compiledict.h \
src/libespeak-ng/dictionary.h \ src/libespeak-ng/dictionary.h \
src/libespeak-ng/error.h \ src/libespeak-ng/error.h \

+ 1
- 0
android/jni/Android.mk View File

LOCAL_SRC_FILES += $(SPEECHPLAYER_SRC_FILES) LOCAL_SRC_FILES += $(SPEECHPLAYER_SRC_FILES)


ESPEAK_SOURCES := \ ESPEAK_SOURCES := \
src/libespeak-ng/common.c \
src/libespeak-ng/compiledata.c \ src/libespeak-ng/compiledata.c \
src/libespeak-ng/compiledict.c \ src/libespeak-ng/compiledict.c \
src/libespeak-ng/compilembrola.c \ src/libespeak-ng/compilembrola.c \

+ 54
- 0
src/libespeak-ng/common.c View File

/*
* Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected]
* Copyright (C) 2013-2017 Reece H. Dunn
*
* 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/>.
*/

#include "config.h"

#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>


#include "common.h"

#pragma GCC visibility push(default)

int GetFileLength(const char *filename)
{
struct stat statbuf;

if (stat(filename, &statbuf) != 0)
return -errno;

if (S_ISDIR(statbuf.st_mode))
return -EISDIR;

return statbuf.st_size;
}

#pragma GCC visibility pop

+ 31
- 0
src/libespeak-ng/common.h View File

/*
* Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: [email protected]
* Copyright (C) 2013-2015 Reece H. Dunn
*
* 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_COMMON_H
#define ESPEAK_NG_COMMON_H

#include "espeak-ng/espeak_ng.h"

extern ESPEAK_NG_API int GetFileLength(const char *filename);

#ifdef __cplusplus
}
#endif

#endif // SPEECH_H

+ 1
- 0
src/libespeak-ng/compiledata.c View File

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "common.h" // for GetFileLength
#include "dictionary.h" // for strncpy0 #include "dictionary.h" // for strncpy0
#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "mnemonics.h" // for LookupMnemName, MNEM_TAB

+ 2
- 1
src/libespeak-ng/dictionary.c View File

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "common.h" // for GetFileLength
#include "dictionary.h" #include "dictionary.h"
#include "numbers.h" // for LookupAccentedLetter, Look... #include "numbers.h" // for LookupAccentedLetter, Look...
#include "phoneme.h" // for PHONEME_TAB, phVOWEL, phon... #include "phoneme.h" // for PHONEME_TAB, phVOWEL, phon...
#include "readclause.h" // for WordToString2, is_str_tota... #include "readclause.h" // for WordToString2, is_str_tota...
#include "speech.h" // for GetFileLength, path_home
#include "speech.h" // for path_home
#include "compiledict.h" // for DecodeRule #include "compiledict.h" // for DecodeRule
#include "synthdata.h" // for PhonemeCode, InterpretPhoneme #include "synthdata.h" // for PhonemeCode, InterpretPhoneme
#include "synthesize.h" // for STRESS_IS_PRIMARY, phoneme... #include "synthesize.h" // for STRESS_IS_PRIMARY, phoneme...

+ 2
- 1
src/libespeak-ng/readclause.c View File

#include <ucd/ucd.h> #include <ucd/ucd.h>


#include "readclause.h" #include "readclause.h"
#include "common.h" // for GetFileLength
#include "config.h" // for HAVE_MKSTEMP #include "config.h" // for HAVE_MKSTEMP
#include "dictionary.h" // for LookupDictList, DecodePhonemes, Set... #include "dictionary.h" // for LookupDictList, DecodePhonemes, Set...
#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context
#include "phoneme.h" // for phonSWITCH #include "phoneme.h" // for phonSWITCH
#include "soundicon.h" // for LookupSoundIcon #include "soundicon.h" // for LookupSoundIcon
#include "speech.h" // for GetFileLength, LookupMnem, PATHSEP
#include "speech.h" // for LookupMnem, PATHSEP
#include "ssml.h" // for SSML_STACK, ProcessSsmlTag, N_PARAM... #include "ssml.h" // for SSML_STACK, ProcessSsmlTag, N_PARAM...
#include "synthdata.h" // for SelectPhonemeTable #include "synthdata.h" // for SelectPhonemeTable
#include "translate.h" // for Translator, utf8_out, CLAUSE_OPTION... #include "translate.h" // for Translator, utf8_out, CLAUSE_OPTION...

+ 2
- 1
src/libespeak-ng/soundicon.c View File

#include <ucd/ucd.h> #include <ucd/ucd.h>


#include "soundicon.h" #include "soundicon.h"
#include "common.h" // for GetFileLength
#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context
#include "readclause.h" // for Read4Bytes #include "readclause.h" // for Read4Bytes
#include "speech.h" // for path_home, GetFileLength, PATHSEP
#include "speech.h" // for path_home, PATHSEP
#include "synthesize.h" // for samplerate #include "synthesize.h" // for samplerate


int n_soundicon_tab = 0; int n_soundicon_tab = 0;

+ 1
- 12
src/libespeak-ng/speech.c View File

#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "speech.h" #include "speech.h"
#include "common.h" // for GetFileLength
#include "dictionary.h" // for GetTranslatedPhonemeString, strncpy0 #include "dictionary.h" // for GetTranslatedPhonemeString, strncpy0
#include "espeak_command.h" // for delete_espeak_command, SetParameter #include "espeak_command.h" // for delete_espeak_command, SetParameter
#include "event.h" // for event_declare, event_clear_all, eve... #include "event.h" // for event_declare, event_clear_all, eve...
return ENS_OK; return ENS_OK;
} }


int GetFileLength(const char *filename)
{
struct stat statbuf;

if (stat(filename, &statbuf) != 0)
return -errno;

if (S_ISDIR(statbuf.st_mode))
return -EISDIR;

return statbuf.st_size;
}


ESPEAK_NG_API void espeak_ng_InitializePath(const char *path) ESPEAK_NG_API void espeak_ng_InitializePath(const char *path)
{ {

+ 0
- 2
src/libespeak-ng/speech.h View File



extern char path_home[N_PATH_HOME]; // this is the espeak-ng-data directory extern char path_home[N_PATH_HOME]; // this is the espeak-ng-data directory


extern ESPEAK_NG_API int GetFileLength(const char *filename);

#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

+ 2
- 1
src/libespeak-ng/synth_mbrola.c View File

#include "wavegen.h" #include "wavegen.h"




#include "speech.h"
#include "common.h"
#include "phoneme.h" #include "phoneme.h"
#include "voice.h" #include "voice.h"
#include "speech.h"
#include "synthesize.h" #include "synthesize.h"
#include "translate.h" #include "translate.h"



+ 2
- 1
src/libespeak-ng/synthdata.c View File

#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "synthdata.h" #include "synthdata.h"
#include "common.h" // for GetFileLength
#include "error.h" // for create_file_error_context, crea... #include "error.h" // for create_file_error_context, crea...
#include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST #include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST
#include "speech.h" // for path_home, GetFileLength, PATHSEP
#include "speech.h" // for path_home, PATHSEP
#include "mbrola.h" // for mbrola_name #include "mbrola.h" // for mbrola_name
#include "soundicon.h" // for soundicon_tab #include "soundicon.h" // for soundicon_tab
#include "synthesize.h" // for PHONEME_LIST, frameref_t, PHONE... #include "synthesize.h" // for PHONEME_LIST, frameref_t, PHONE...

+ 2
- 1
src/libespeak-ng/voices.c View File

#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "voice.h" // for voice_t, DoVoiceChange, N_PEAKS #include "voice.h" // for voice_t, DoVoiceChange, N_PEAKS
#include "common.h" // for GetFileLength
#include "dictionary.h" // for strncpy0, LoadDictionary #include "dictionary.h" // for strncpy0, LoadDictionary
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho... #include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho...
#include "speech.h" // for GetFileLength, PATHSEP
#include "speech.h" // for PATHSEP
#include "mbrola.h" // for LoadMbrolaTable #include "mbrola.h" // for LoadMbrolaTable
#include "synthdata.h" // for SelectPhonemeTableName, LookupP... #include "synthdata.h" // for SelectPhonemeTableName, LookupP...
#include "synthesize.h" // for SetSpeed, SPEED_FACTORS, speed #include "synthesize.h" // for SetSpeed, SPEED_FACTORS, speed

+ 1
- 1
tests/fuzzrunner.c View File

*/ */


#include "config.h" #include "config.h"
#include "speech.h"
#include "common.h"


#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>

Loading…
Cancel
Save