[med-svn] [praat] 02/04: d/p/espeak-big-endian.patch: New patch

Rafael Laboissiere rafael at debian.org
Thu Nov 30 05:03:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

rafael pushed a commit to branch master
in repository praat.

commit c5f821490d7840505a61c3df9ae0c7a081e2c18f
Author: Rafael Laboissiere <rafael at debian.org>
Date:   Wed Nov 29 18:01:32 2017 -0200

    d/p/espeak-big-endian.patch: New patch
---
 debian/patches/espeak-big-endian.patch | 705 +++++++++++++++++++++++++++++++++
 debian/patches/series                  |   1 +
 2 files changed, 706 insertions(+)

diff --git a/debian/patches/espeak-big-endian.patch b/debian/patches/espeak-big-endian.patch
new file mode 100644
index 0000000..96bcc96
--- /dev/null
+++ b/debian/patches/espeak-big-endian.patch
@@ -0,0 +1,705 @@
+Description: Fix espeak code for big endian systems
+ This patch was taken form the upstream Git repository.
+Author: Rafael Laboissiere <rafael at debian.org>
+Forwarded: not-needed
+Last-Update: 2017-11-29
+
+--- praat-6.0.36.orig/external/espeak/dictionary.cpp
++++ praat-6.0.36/external/espeak/dictionary.cpp
+@@ -87,23 +87,6 @@ void strncpy0(char *to, const char *from
+ }
+ #pragma GCC visibility pop
+ 
+-int Reverse4Bytes(int word)
+-{
+-	// reverse the order of bytes from little-endian to big-endian
+-#ifdef ARCH_BIG
+-	int ix;
+-	int word2 = 0;
+-
+-	for (ix = 0; ix <= 24; ix += 8) {
+-		word2 = word2 << 8;
+-		word2 |= (word >> ix) & 0xff;
+-	}
+-	return word2;
+-#else
+-	return word;
+-#endif
+-}
+-
+ static void InitGroups(Translator *tr)
+ {
+ 	// Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains
+@@ -112,7 +95,6 @@ static void InitGroups(Translator *tr)
+ 	int ix;
+ 	char *p;
+ 	char *p_name;
+-	unsigned int *pw;
+ 	unsigned char c, c2;
+ 	int len;
+ 
+@@ -134,21 +116,20 @@ static void InitGroups(Translator *tr)
+ 		p++;
+ 
+ 		if (p[0] == RULE_REPLACEMENTS) {
+-			pw = (unsigned int *)(((intptr_t)p+4) & ~3); // advance to next word boundary
+-			tr->langopts.replace_chars = pw;
+-			while (pw[0] != 0)
+-				pw += 2; // find the end of the replacement list, each entry is 2 words.
+-			p = (char *)(pw+1);
+-
+-#ifdef ARCH_BIG
+-			pw = (unsigned int *)(tr->langopts.replace_chars);
+-			while (*pw != 0) {
+-				*pw = Reverse4Bytes(*pw);
+-				pw++;
+-				*pw = Reverse4Bytes(*pw);
+-				pw++;
++			//(unsigned int *)pw = (unsigned int *)(((intptr_t)p+4) & ~3); // advance to next word boundary
++			p += 4;
++			while ((size_t)p % 4 > 0) { p --; }
++			
++			tr->langopts.replace_chars = (unsigned int *) p;
++			
++			int i32 = get_set_int32_le (p);
++			while (i32 != 0) {
++				p += 4;
++				get_set_int32_le (p);
++				p += 4;
++				i32 = get_set_int32_le (p);
+ 			}
+-#endif
++			p += 4;
+ 			continue;
+ 		}
+ 
+@@ -194,7 +175,6 @@ int LoadDictionary(Translator *tr, const
+ {
+ 	int hash;
+ 	char *p;
+-	int *pw;
+ 	int length;
+ 	FILE *f;
+ 	int size;
+@@ -230,17 +210,17 @@ int LoadDictionary(Translator *tr, const
+ 	size = fread(tr->data_dictlist, 1, size, f);
+ 	fclose(f);
+ 
+-	pw = (int *)(tr->data_dictlist);
+-	length = Reverse4Bytes(pw[1]);
++	int hash_number = get_int32_le (tr->data_dictlist);
++	length = get_int32_le (tr->data_dictlist + 4);
+ 
+ 	if (size <= (N_HASH_DICT + sizeof(int)*2)) {
+ 		fprintf(stderr, "Empty _dict file: '%s\n", fname);
+ 		return 2;
+ 	}
+ 
+-	if ((Reverse4Bytes(pw[0]) != N_HASH_DICT) ||
++	if ((hash_number != N_HASH_DICT) ||
+ 	    (length <= 0) || (length > 0x8000000)) {
+-		fprintf(stderr, "Bad data: '%s' (%x length=%x)\n", fname, Reverse4Bytes(pw[0]), length);
++		fprintf(stderr, "Bad data: '%s' (%x length=%x)\n", fname, hash_number, length);
+ 		return 2;
+ 	}
+ 	tr->data_dictrules = &(tr->data_dictlist[length]);
+@@ -2393,7 +2373,7 @@ int TranslateRules(Translator *tr, char
+ 						match1.end_type |= p - p_start;
+ 					}
+ 					strcpy(end_phonemes, match1.phonemes);
+-					strcpy(p_start, word_copy);
++					memcpy(p_start, word_copy, strlen(word_copy));
+ 					return match1.end_type;
+ 				}
+ 			}
+@@ -2403,7 +2383,7 @@ int TranslateRules(Translator *tr, char
+ 		}
+ 	}
+ 
+-	strcpy(p_start, word_copy);
++	memcpy(p_start, word_copy, strlen(word_copy));
+ 
+ 	return 0;
+ }
+--- praat-6.0.36.orig/external/espeak/espeak_io.cpp
++++ praat-6.0.36/external/espeak/espeak_io.cpp
+@@ -24,7 +24,7 @@
+ #include "espeakdata_FileInMemory.h"
+ #include "espeak_ng.h"
+ #include "speech.h"
+-#include "voice.h"
++#include "synthesize.h"
+ #include <errno.h>
+ 
+ extern autoFileInMemoryManager espeak_ng_FileInMemoryManager;
+@@ -139,4 +139,239 @@ void espeak_io_GetVoices (const char *pa
+ 	}
+ }
+ 
++int get_int32_le (char *byte) {
++	return (((uint8)byte[0]<<0) | ((uint8)byte[1]<<8) | ((uint8)byte[2]<<16) | ((uint8)byte[3]<<24));
++}
++
++short get_int16_le (char *byte) {
++       return (((uint8)byte[0]<<0) | ((uint8)byte[1]<<8));
++}
++
++int get_set_int32_le (char *byte) {
++       int i32 = (((uint8)byte[0]<<0) | ((uint8)byte[1]<<8) | ((uint8)byte[2]<<16) | ((uint8)byte[3]<<24));
++       int *p32 = (int *) byte;
++       *p32 = i32;
++       return i32;
++}
++
++/*
++	The espeak-ng data files have been written with little endian byte order. To be able to use these files on big endian hardware we have to change these files as if they were written on a big endian machine.
++	The following routines were modeled after espeak-phonemedata.c by Jonathan Duddington.
++	A serious bug in his code for the phontab_to_bigendian procedure has been corrected.
++	A better solution would be:
++		espeak-ng should read a little endian int32 as 4 unsigned bytes:
++			int32 i = (byte[0]<<0) | (byte[1]<<8) | (byte[2]<<16) | (byte[3]<<24);
++		a int16 (short) as 2 unsigned bytes:
++			int16 i = (byte[0]<<0) | (byte[1]<<8);
++		Then no conversion of data files would be necessary.
++
++*/
++
++#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
++	#define SWAP_2(i1) { integer i2 = i1 + 1; \
++		thy d_data [i1] = my d_data [i2]; \
++		thy d_data [i2] = my d_data [i1]; }
++
++	#define SWAP_4(i1) { integer i2 = i1 + 1, i3 = i1 + 2, i4 = i1 + 3; \
++		thy d_data [i1] = my d_data [i4]; \
++		thy d_data [i2] = my d_data [i3]; \
++		thy d_data [i3] = my d_data [i2]; \
++		thy d_data [i4] = my d_data [i1]; }
++#else
++	#define SWAP_2(i1)
++	#define SWAP_4(i1)
++#endif
++
++static autoFileInMemory phondata_to_bigendian (FileInMemory me, FileInMemory manifest) {
++	try {
++		autoFileInMemory thee = Data_copy (me);
++		FILE *phondataf = fopen (Melder_peek32to8 (my d_path), "r");
++		FILE *manifestf = fopen (Melder_peek32to8 (manifest -> d_path), "r");
++		char line [1024];
++		// copy 4 bytes: version number
++		// copy 4 bytes: sample rate
++		while (fgets (line, sizeof (line), manifestf)) {
++			if (! isupper (line [0])) continue;
++			unsigned int index;
++			sscanf(& line [2], "%x", & index);
++			fseek (phondataf, index, SEEK_SET);
++			integer i1 = index;
++			if (line [0] == 'S') { // 
++				/*
++					typedef struct {
++						short length;
++						unsigned char n_frames;
++						unsigned char sqflags;
++						frame_t frame[N_SEQ_FRAMES];
++					} SPECT_SEQ;
++				*/
++
++				SWAP_2 (i1)
++				index += 2; // skip the short length
++				integer numberOfFrames = my d_data [index]; // unsigned char n_frames
++				index += 2; // skip the 2 unsigned char's n_frames & sqflags
++				
++				for (integer n = 1; n <= numberOfFrames; n ++) {
++					/* 
++						typedef struct { //64 bytes
++							short frflags;
++							short ffreq[7];
++							unsigned char length;
++							unsigned char rms;
++							unsigned char fheight[8];
++							unsigned char fwidth[6];          // width/4  f0-5
++							unsigned char fright[3];          // width/4  f0-2
++							unsigned char bw[4];        // Klatt bandwidth BNZ /2, f1,f2,f3
++							unsigned char klattp[5];    // AV, FNZ, Tilt, Aspr, Skew
++							unsigned char klattp2[5];   // continuation of klattp[],  Avp, Fric, FricBP, Turb
++							unsigned char klatt_ap[7];  // Klatt parallel amplitude
++							unsigned char klatt_bp[7];  // Klatt parallel bandwidth  /2
++							unsigned char spare;        // pad to multiple of 4 bytes
++						} frame_t;   //  with extra Klatt parameters for parallel resonators
++
++						typedef struct {  // 44 bytes
++							short frflags;
++							short ffreq[7];
++							unsigned char length;
++							unsigned char rms;
++							unsigned char fheight[8];
++							unsigned char fwidth[6];          // width/4  f0-5
++							unsigned char fright[3];          // width/4  f0-2
++							unsigned char bw[4];        // Klatt bandwidth BNZ /2, f1,f2,f3
++							unsigned char klattp[5];    // AV, FNZ, Tilt, Aspr, Skew
++						} frame_t2;
++						Both frame_t and frame_t2 start with 8 short's.
++					*/
++					i1 = index;
++					for (integer i = 1; i <= 8; i ++) {
++						SWAP_2 (i1)
++						i1 += 2;
++					}
++					// 
++					#define FRFLAG_KLATT 0x01
++					index += (thy d_data [i1] & FRFLAG_KLATT) ? sizeof (frame_t) : sizeof (frame_t2); // thy is essential!
++				}				
++			} else if (line [0] == 'W') { // Wave data
++				int length = my d_data [i1 + 1] * 256 + my d_data [i1];
++				index += 4;
++				
++				index += length; // char wavedata[length]
++				
++				index += index % 3;
++				
++			} else if (line [0] == 'E') {
++				
++				index += 128; // Envelope: skip 128 bytes
++				
++				
++			} else if (line [0] == 'Q') {
++				unsigned int length = my d_data [index + 2] << 8 + my d_data [index + 3];
++				length *= 4;
++				
++				index += length;
++			}
++			Melder_require (index <= my d_numberOfBytes, U"Position ", index, U"is larger than file length (", my d_numberOfBytes, U")."); 
++		}
++		return thee;
++	} catch (MelderError) {
++		Melder_throw (U"phondata not converted to bigendian.");
++	}
++}
++
++static autoFileInMemory phontab_to_bigendian (FileInMemory me) {
++	try {
++		autoFileInMemory thee = Data_copy (me);
++		integer numberOfPhonemeTables = my d_data [0];
++		integer index = 4; // skip first 4 bytes
++		for (integer itab = 1; itab <= numberOfPhonemeTables; itab ++) {
++			integer numberOfPhonemes = thy d_data [index];
++			
++			index += 4; // This is 8 (incorrect) in the original code of espeak.
++			
++			index += N_PHONEME_TAB_NAME; // skip the name
++			integer phonemeTableSizes = numberOfPhonemes * sizeof (PHONEME_TAB);
++			Melder_require (index + phonemeTableSizes <= my d_numberOfBytes, U"Too many tables to process. (table ", itab, U" from ", numberOfPhonemeTables, U").");
++			for (integer j = 1; j <= numberOfPhonemes; j ++) {
++				/*
++					typedef struct { // 16 bytes
++						unsigned int  mnemonic;      // 1st char is in the l.s.byte
++						unsigned int  phflags;       // bits 16-19 place of articulation
++						unsigned short program;
++						unsigned char  code;         // the phoneme number
++						unsigned char  type;         // phVOWEL, phPAUSE, phSTOP etc
++						unsigned char  start_type;
++						unsigned char  end_type;
++						unsigned char  std_length;   // for vowels, in mS/2;  for phSTRESS, the stress/tone type
++						unsigned char  length_mod;   // a length_mod group number, used to access length_mod_tab
++					} PHONEME_TAB;
++				*/
++				integer i1 = index;
++				SWAP_4 (i1)				
++				i1 += 4;
++				SWAP_4 (i1);
++				i1 += 4;
++				SWAP_2 (i1)
++				index += sizeof (PHONEME_TAB);
++			}
++			Melder_require (index <= my d_numberOfBytes, U"Position ", index, U" is larger than file length (", my d_numberOfBytes, U").");
++		}
++		return thee;
++	} catch (MelderError) {
++		Melder_throw (U"phontab not converted to bigendian.");
++	}
++}
++	
++static autoFileInMemory phonindex_to_bigendian (FileInMemory me) {
++	try {
++		autoFileInMemory thee = Data_copy (me);
++		integer numberOfShorts = (my d_numberOfBytes - 4 - 1) / 2;
++		integer index = 4; // skip first 4 bytes
++		for (integer i = 0; i < numberOfShorts; i ++) {
++			SWAP_2 (index)
++			index += 2;
++			Melder_require (index <= my d_numberOfBytes, U"Position ", index, U" is larger than file length (", my d_numberOfBytes, U").");
++		}
++		return thee;
++	} catch (MelderError) {
++		Melder_throw (U"phonindex not converted to bigendian.");
++	}
++}
++
++void espeak_ng_data_to_bigendian () {
++	FileInMemoryManager me = ESPEAK_FILEINMEMORYMANAGER;
++	autoMelderString file;
++
++	MelderString_append (& file, Melder_peek8to32 (PATH_ESPEAK_DATA), U"/phondata-manifest");
++	integer index = FileInMemorySet_lookUp (my files.get(), file.string);
++	Melder_require (index > 0, U"phondata-manifest not present.");
++	FileInMemory manifest = (FileInMemory) my files -> at [index];
++
++	MelderString_empty (& file);
++	MelderString_append (& file, Melder_peek8to32 (PATH_ESPEAK_DATA), U"/phondata");
++	index = FileInMemorySet_lookUp (my files.get(), file.string);
++	Melder_require (index > 0, U"phondata not present.");
++	FileInMemory phondata = (FileInMemory) my files -> at [index];
++
++	autoFileInMemory phondata_new = phondata_to_bigendian (phondata, manifest);
++	my files -> replaceItem_move (phondata_new.move(), index);
++
++	MelderString_empty (& file);
++	MelderString_append (& file, Melder_peek8to32 (PATH_ESPEAK_DATA), U"/phontab");
++	index = FileInMemorySet_lookUp (my files.get(), file.string);
++	Melder_require (index > 0, U"phonindex not present.");
++	FileInMemory phontab = (FileInMemory) my files -> at [index];
++
++	autoFileInMemory phontab_new = phontab_to_bigendian (phontab);	
++	my files -> replaceItem_move (phontab_new.move(), index);
++
++	MelderString_empty (& file);
++	MelderString_append (& file, Melder_peek8to32 (PATH_ESPEAK_DATA), U"/phonindex");
++	index = FileInMemorySet_lookUp (my files.get(), file.string);
++	Melder_require (index > 0, U"phonindex not present.");
++	FileInMemory phonindex = (FileInMemory) my files -> at [index];
++
++	autoFileInMemory phonindex_new = phonindex_to_bigendian (phonindex);	
++	my files -> replaceItem_move (phonindex_new.move(), index);
++}
++
+ /* End of file espeak_io.cpp */
+--- praat-6.0.36.orig/external/espeak/espeak_io.h
++++ praat-6.0.36/external/espeak/espeak_io.h
+@@ -62,4 +62,12 @@ int espeak_io_GetFileLength (const char
+ 
+ void espeak_io_GetVoices (const char *path, int len_path_voices, int is_language_file);
+ 
++void espeak_ng_data_to_bigendian (void);
++
++int get_int32_le (char *byte);
++
++short get_int16_le (char *byte);
++
++int get_set_int32_le (char *byte); 
++
+ #endif
+--- /dev/null
++++ praat-6.0.36/external/espeak/espeak_ng_data_to_code.praat
+@@ -0,0 +1,188 @@
++# espeak_ng_data_to_code.praat
++# djmw 20120117, 20120124, 20151130, 20171004
++#
++# This script is specific for my situation (althought it can be adapted easily to any directory structure
++#	and non-Linux system).
++#	My espeak-work/ has subdirectories espeak-ng-work and espeak-ng-current.
++# 	Into espeak-ng-work are copied from the original espeak-ng project only those *.c and *.h files that are 
++# 	needed for the praat version of the synthesizer .
++#
++# If the upstream espeak-ng has been modified then I follow the following procedure:
++#
++# Given the following directories:
++#	A: ~/projects/praat/espeak-work/espeak-ng-work 
++#	B: ~/projects/praat/espeak-work/espeak-ng-current
++#	C: ~/projects/praat/external/espeak 
++#
++#	0. I pull the sources from upstream:
++#		cd ~/projects/espeak-ng
++#		- git pull https://github.com/espeak-ng/espeak-ng.git
++#		- make clean
++#		- make
++#		- Get the version of espeak-ng from the ~/projects/espeak-ng/config.h file
++#	1. I copy the necessary *.c and *.h files from ~/projects/espeak-ng/src/... to espeak-work 
++#		by running this script with only the option "Copy_c_and_h_files" ON (the right version option).
++#		The *.c files are renamed as *.cpp files. Also a new file espeak-ng-version.h is created.
++#	2. I use a three-way diff program (kdiff3) to see which files in A are different from B and 
++#		merge the differences into C.
++#	3. Now my *.cpp and *.h are in synchrony with upstream and we copy all files from A to B.
++#	4. I generate the new dictionaries and language files in memory by running this script
++#		with only the option "Create_FileInMemorySet" set to ON.
++#	5. I copy the file create_espeak_ng_FileInMemorySet.cpp 
++#  		and espeak-ng-version.h from espeak-ng-work/ to external/espeak
++#	6. Now the praat synthesizer is up to date.
++# 
++# Function of this script:
++# Generates in espeak-ng-work
++# 	1. create_espeak_ng_FileInMemorySet.cpp
++# 	2. espeak-ng-version.h
++#
++# 	and
++#
++# 	3. Copies the necessary *.c(pp) and *.h from from_dir to to_dir
++#
++
++myscriptname$ = "espeak_ng_data_to_code.praat"
++date$ = date$()
++notify$ = "This file was created automatically on " + date$ + "."
++clearinfo
++
++form Espeakdata to code
++	word Espeak_version 1.49.3-dev
++	boolean Copy_c_and_h_files 0
++	boolean Show_cp_command 1
++	boolean Create_FileInMemorySet 0
++endform
++
++gpltext$ =  " * Copyright (C) David Weenink 2012-2017" + newline$ +
++	... " *" + newline$ +
++	... " * This program is free software; you can redistribute it and/or modify " + newline$ +
++ 	... " * it under the terms of the GNU General Public License as published by" + newline$ +
++ 	... " * the Free Software Foundation; either version 2 of the License, or (at" + newline$ +
++ 	... " * your option) any later version." + newline$ +
++  	... " *" + newline$ +
++  	... " * This program is distributed in the hope that it will be useful, but" + newline$ +
++ 	... " * WITHOUT ANY WARRANTY; without even the implied warranty of" + newline$ +
++  	... " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU" + newline$ +
++ 	... " * General Public License for more details." + newline$ +
++ 	... " *" + newline$ +
++  	... " * You should have received a copy of the GNU General Public License" + newline$ +
++  	... " * along with this program; if not, write to the Free Software" + newline$ +
++ 	... " * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA." + newline$
++
++fromdir$ = "/home/david/projects/espeak-ng"
++todir$ = "/home/david/projects/praat/espeak-work/espeak-ng-work"
++
++espeakdata_dir$ = fromdir$ + "/espeak-ng-data"
++espeakdata_voices_dir$ = espeakdata_dir$ + "/voices/!v"
++espeakdata_lang_dir$ = espeakdata_dir$ + "/lang"
++
++include_header$ = "#include "+ """" + "espeakdata_FileInMemory.h" + """" + newline$
++
++if create_FileInMemorySet
++
++	@create_phonFileInMemorySet
++
++	@create_languageFileInMemorySet
++
++	dict_fims = Create FileInMemorySet from directory contents: "list", espeakdata_dir$, "*_dict"
++	
++	voice_fims = Create FileInMemorySet from directory contents: "voices", espeakdata_dir$ + "/voices/!v", "*"
++
++	selectObject: language_fims, phon_fims, dict_fims, voice_fims
++	espeak_ng_fims = Merge
++	
++	.message$ = "/* espeak_ng_createFileInMemorySet.cpp" + newline$
++	... + " * This file was automatically created from files in directories in espeak-ng-data." + newline$
++	... + " * Espeak-ng version: " + espeak_version$ + "." + newline$
++	... + " * Date: " + date$() + "." + newline$
++	... + "*/" + newline$ +newline$
++	... + "#include ""espeakdata_FileInMemory.h""" + newline$
++	.cpp$ = Show as code: "espeak_ng_FileInMemorySet", 30
++	.cpp$ = .message$ + .cpp$ 
++	writeInfoLine: .cpp$
++	writeFile: todir$ + "/create_espeak_ng_FileInMemorySet.cpp", .cpp$
++endif
++
++procedure create_phonFileInMemorySet
++	fim1 = Create FileInMemory: espeakdata_dir$ + "/phondata"
++	fim2 = Create FileInMemory: espeakdata_dir$ + "/phonindex"
++	fim3 = Create FileInMemory: espeakdata_dir$ + "/phontab"
++	fim4 = Create FileInMemory: espeakdata_dir$ + "/intonations"
++	fim5 = Create FileInMemory: espeakdata_dir$ + "/phondata-manifest"
++	selectObject: fim1, fim2, fim3, fim4, fim5
++	phon_fims = To FileInMemorySet
++	removeObject: fim1, fim2, fim3, fim4, fim5
++endproc
++
++procedure create_languageFileInMemorySet
++	language_fims = Create FileInMemorySet from directory contents: "l", espeakdata_lang_dir$, "*"
++	.ldirs =  Create Strings as directory list: "dirs",  espeakdata_lang_dir$+ "/*"
++	.ndirs = Get number of strings
++	for .idir to .ndirs
++		selectObject: .ldirs
++		.dir$ = Get string: .idir
++		.langset = Create FileInMemorySet from directory contents: "l", espeakdata_lang_dir$ + "/" + .dir$ , "*"
++		plusObject: language_fims
++		.merged = Merge
++		removeObject: .langset, language_fims
++		language_fims = .merged
++	endfor
++	removeObject: .ldirs
++endproc
++
++# extract only the necesary files to espeak-ng-work.
++# changes to these files have to be made in espeak-ng-current
++
++if copy_c_and_h_files
++	@espeak_ng_copyfiles
++endif
++
++procedure espeak_ng_copyfiles
++	.espeakfiles_c$ = "compiledata.c compiledict.c compilembrola.c dictionary.c" +
++	... " encoding.c error.c espeak_api.c espeak_command.c" +
++	... " event.c fifo.c ieee80.c intonation.c klatt.c" +
++	... " mnemonics.c numbers.c phoneme.c phonemelist.c readclause.c setlengths.c" +
++	... " spect.c speech.c synthdata.c synthesize.c " +
++	... " synth_mbrola.c translate.c tr_languages.c voices.c wavegen.c"
++
++	.espeakfiles_h$ = "error.h espeak_command.h event.h fifo.h klatt.h phoneme.h sintab.h" +
++	... " spect.h speech.h synthesize.h translate.h voice.h synthesize.h translate.h voice.h"
++	.espeakfiles_include_h$ = "speak_lib.h espeak_ng.h encoding.h"
++	.espeakfiles_ucd_h$ = "ucd.h"
++	.espeakfiles_ucd_c$ = "case.c categories.c proplist.c"
++
++	# check version
++	.config$ = readFile$ ("~/projects/espeak-ng/config.h")
++	.version$ = extractWord$ (.config$, "#define VERSION """)
++	.version$ = replace$ (.version$, """", "", 0)
++	if .version$ <> espeak_version$
++		exitScript: "The given version (", espeak_version$, ") differs from package version ", .version$
++	endif
++
++	# rename and cp files from espeak-ng to espeak-work
++	@copy_rename: fromdir$+"/src/libespeak-ng", .espeakfiles_c$, ".c", ".cpp"
++	@copy_rename: fromdir$+"/src/libespeak-ng", .espeakfiles_h$, ".h", ".h"
++	@copy_rename: fromdir$+"/src/include/espeak-ng", .espeakfiles_include_h$, ".h", ".h"
++	@copy_rename: fromdir$+"/src/ucd-tools/src", .espeakfiles_ucd_c$, ".c", ".cpp"
++	@copy_rename: fromdir$+"/src/ucd-tools/src/include/ucd", .espeakfiles_ucd_h$, ".h", ".h"
++	.version_define$ = "#define ESPEAK_NG_VERSION " + "U""" + espeak_version$ + """" + newline$
++		... + "#define ESPEAK_NG_VERSIONX " + espeak_version$
++	writeFile: todir$ + "/espeak_ng_version.h", .version_define$
++endproc
++
++procedure copy_rename: .fromdir$, .files$, .ext$, .newext$
++	.list = Create Strings as tokens: .files$
++	.numberOfFiles = Get number of strings
++	for .ifile to .numberOfFiles
++		.name$ = Get string: .ifile
++		.newname$ = .name$ - .ext$ + .newext$
++		.command$ =  "cp " + .fromdir$ + "/" + .name$ + " " + todir$ + "/" + .newname$
++		appendInfoLine: .command$
++		if show_cp_command
++			appendInfoLine: .command$
++		endif
++		runSystem: .command$
++	endfor
++endproc
++
+--- praat-6.0.36.orig/external/espeak/espeakdata_FileInMemory.cpp
++++ praat-6.0.36/external/espeak/espeakdata_FileInMemory.cpp
+@@ -19,6 +19,7 @@
+ 
+ // The glue between Praat and espeak
+ 
++
+ #include "NUM2.h"
+ #include "espeak_ng.h"
+ #include "FileInMemoryManager.h"
+@@ -58,6 +59,10 @@ void espeakdata_praat_init () {
+ 		espeakdata_voices_propertiesTable = Table_createAsEspeakVoicesProperties ();
+ 		espeakdata_languages_names = Table_column_to_Strings (espeakdata_languages_propertiesTable.get(), 2);
+ 		espeakdata_voices_names = Table_column_to_Strings (espeakdata_voices_propertiesTable.get(), 2);
++		int test = 1;
++		if (* ((char *) & test) != 1) { // (too?) simple endian test
++			espeak_ng_data_to_bigendian ();
++		}
+ 	} catch (MelderError) {
+ 		Melder_throw (U"Espeakdata initialization not performed.");
+ 	}
+--- praat-6.0.36.orig/external/espeak/readclause.cpp
++++ praat-6.0.36/external/espeak/readclause.cpp
+@@ -299,16 +299,10 @@ static const char *LookupCharName(Transl
+ 
+ int Read4Bytes(FILE *f)
+ {
+-	// Read 4 bytes (least significant first) into a word
+-	int ix;
+-	unsigned char c;
+-	int acc = 0;
+-
+-	for (ix = 0; ix < 4; ix++) {
+-		c = fgetc(f) & 0xff;
+-		acc += (c << (ix*8));
+-	}
+-	return acc;
++	// Read 4 bytes (least significant first) into a int32
++	char p4 [4];
++	fread (p4, 1, 4, f);
++	return get_int32_le (p4);
+ }
+ 
+ static espeak_ng_STATUS LoadSoundFile(const char *fname, int index, espeak_ng_ERROR_CONTEXT *context)
+@@ -399,8 +393,8 @@ static espeak_ng_STATUS LoadSoundFile(co
+ 	fclose(f);
+ 	remove(fname_temp);
+ 
+-	ip = (int *)(&p[40]);
+-	soundicon_tab[index].length = (*ip) / 2; // length in samples
++	int i32 = get_int32_le (p + 40); // ip = (int *)(&p[40]);
++	soundicon_tab[index].length = i32 / 2; // length in samples
+ 	soundicon_tab[index].data = p;
+ 	return ENS_OK;
+ }
+--- praat-6.0.36.orig/external/espeak/synthdata.cpp
++++ praat-6.0.36/external/espeak/synthdata.cpp
+@@ -123,12 +123,9 @@ espeak_ng_STATUS LoadPhData(int *srate,
+ 	n_tunes = length / sizeof(TUNE);
+ 
+ 	// read the version number and sample rate from the first 8 bytes of phondata
+-	version = 0; // bytes 0-3, version number
+-	rate = 0;    // bytes 4-7, sample rate
+-	for (ix = 0; ix < 4; ix++) {
+-		version += (wavefile_data[ix] << (ix*8));
+-		rate += (wavefile_data[ix+4] << (ix*8));
+-	}
++	
++	version = get_int32_le ((char *) wavefile_data); // bytes 0-3, version number
++	rate = get_int32_le ((char *) (wavefile_data + 4)); // bytes 4-7, sample rate
+ 
+ 	if (version != version_phdata)
+ 		return create_version_mismatch_error_context(context, path_home, version, version_phdata);
+@@ -755,7 +752,7 @@ int NumInstnWords(USHORT *prog)
+ 			// This instruction is followed by addWav(), 2 more words
+ 			return 4;
+ 		}
+-		if (instn2 == OPCODE_CONTINUE)
++		if (instn2 == INSTN_CONTINUE)
+ 			return 3;
+ 		return 2;
+ 	}
+@@ -812,10 +809,10 @@ void InterpretPhoneme(Translator *tr, in
+ 				// instructions with no operand
+ 				switch (data)
+ 				{
+-				case OPCODE_RETURN:
++				case INSTN_RETURN:
+ 					end_flag = 1;
+ 					break;
+-				case OPCODE_CONTINUE:
++				case INSTN_CONTINUE:
+ 					break;
+ 				default:
+ 					InvalidInstn(ph, instn);
+@@ -953,7 +950,7 @@ void InterpretPhoneme(Translator *tr, in
+ 			param_sc = phdata->sound_param[instn2] = (instn >> 4) & 0xff;
+ 			prog++;
+ 
+-			if (prog[1] != OPCODE_CONTINUE) {
++			if (prog[1] != INSTN_CONTINUE) {
+ 				if (instn2 < 2) {
+ 					// FMT() and WAV() imply Return
+ 					end_flag = 1;
+--- praat-6.0.36.orig/external/espeak/synthesize.h
++++ praat-6.0.36/external/espeak/synthesize.h
+@@ -269,8 +269,8 @@ typedef struct {
+ 
+ // instructions
+ 
+-#define OPCODE_RETURN        0x0001
+-#define OPCODE_CONTINUE      0x0002
++#define INSTN_RETURN         0x0001
++#define INSTN_CONTINUE       0x0002
+ 
+ // Group 0 instrcutions with 8 bit operand.  These values go into bits 8-15 of the instruction
+ #define i_CHANGE_PHONEME 0x01
+@@ -506,7 +506,6 @@ int  SelectPhonemeTableName(const char *
+ 
+ void Write4Bytes(FILE *f, int value);
+ int Read4Bytes(FILE *f);
+-int Reverse4Bytes(int word);
+ 
+ #define ENV_LEN  128    // length of pitch envelopes
+ #define PITCHfall   0  // standard pitch envelopes
diff --git a/debian/patches/series b/debian/patches/series
index 32c709b..3f72de4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 use-ldflags.patch
 remove-time-date-macros.patch
 fix-gsl-unit-test.patch
+espeak-big-endian.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/praat.git



More information about the debian-med-commit mailing list