diff --git a/EspeakFrontend.py b/EspeakFrontend.py new file mode 100644 index 0000000..4bd2d9a --- /dev/null +++ b/EspeakFrontend.py @@ -0,0 +1,70 @@ +## +# Project: gespeaker - A GTK frontend for espeak +# Author: Muflone Ubuntu Trucchi +## + +import SubprocessWrapper + +class EspeakFrontend(object): + def __init__(self): + self.procTalk = None + print 'python version detected: %d.%d' % ( + SubprocessWrapper.PYTHON_VERSION[0], SubprocessWrapper.PYTHON_VERSION[1]) + + def isPlaying(self): + "Check if a process is still running" + return self.procTalk and ( + self.procTalk[0].poll() == None or self.procTalk[1].poll() == None) + + def pauseOrResume(self, status): + "Pause or Resume the playing, based on status" + if self.procTalk: + # Check if espeak is still runnning + if self.procTalk[0].poll() == None: + if status: + self.procTalk[0].stop() + else: + self.procTalk[0].resume() + # Check if player is still runnning + if self.procTalk[1].poll() == None: + if status: + self.procTalk[1].stop() + else: + self.procTalk[1].resume() + + def play(self, cmdEspeak, cmdPlayer): + "Play the command provided" + # Execute espeak and pipe it with player + procEspeak = SubprocessWrapper.Popen(cmdEspeak.split(), + stdout=SubprocessWrapper.PIPE) + procPlay = SubprocessWrapper.Popen(cmdPlayer.split(), + stdin=procEspeak.stdout, + stdout=SubprocessWrapper.PIPE, + stderr=SubprocessWrapper.PIPE) + # Save both processes espeak and player + self.procTalk = (procEspeak, procPlay) + + def stop(self): + "Stop audio killing espeak and player" + # If played at least once then we have procTalk + if self.procTalk: + # Check if espeak is still running + if self.procTalk[0].poll() == None: + print 'killing espeak with pid %d' % self.procTalk[0].pid + self.procTalk[0].terminate() + # Check if player is still runnning + if self.procTalk[1].poll() == None: + print 'killing player with pid %d' % self.procTalk[1].pid + self.procTalk[1].terminate() + # We don't need processes anymore + self.procTalk = None + return True + else: + return False + + def loadLanguages(self, cmdEspeak): + "Load languages list from espeak" + print 'loading languages from %s --voices' % cmdEspeak + proc = SubprocessWrapper.Popen((cmdEspeak, '--voices'), + stdout=SubprocessWrapper.PIPE) + return proc.communicate()[0].split('\n')[1:-1] diff --git a/SubprocessWrapper.py b/SubprocessWrapper.py new file mode 100644 index 0000000..0194ccf --- /dev/null +++ b/SubprocessWrapper.py @@ -0,0 +1,51 @@ +## +# Project: gespeaker - A GTK frontend for espeak +# Author: Muflone Ubuntu Trucchi +## + +import subprocess +import sys +import os + +PIPE = subprocess.PIPE +PYTHON_VERSION = sys.version_info[0:2] + +class Popen(object): + def __init__(self, args, stdin=None, stdout=None, stderr=None, shell=False): + self.process = subprocess.Popen(args=args, + stdin=stdin, stdout=stdout, stderr=stderr, shell=shell) + self.stdin = self.process.stdin + self.stdout = self.process.stdout + self.stderr = self.process.stderr + self.pid = self.process.pid + + def __del__(self): + self.process = None + + def communicate(self): + return self.process.communicate() + + def poll(self): + return self.process.poll() + + def terminate(self): + "Python version < 2.6 doesn't have a terminate method for subprocess" + if PYTHON_VERSION[0] == 2 and PYTHON_VERSION[1] >= 6: + return self.process.terminate() + else: + signal = 15 + return os.kill(self.pid, signal) + + def stop(self): + signal = 19 + if PYTHON_VERSION[0] == 2 and PYTHON_VERSION[1] >= 6: + return self.process.send_signal(signal) + else: + return os.kill(self.pid, signal) + + def resume(self): + signal = 18 + if PYTHON_VERSION[0] == 2 and PYTHON_VERSION[1] >= 6: + return self.process.send_signal(signal) + else: + return os.kill(self.pid, signal) diff --git a/TempfileWrapper.py b/TempfileWrapper.py new file mode 100644 index 0000000..ce9ddd6 --- /dev/null +++ b/TempfileWrapper.py @@ -0,0 +1,39 @@ +## +# Project: gespeaker - A GTK frontend for espeak +# Author: Muflone Ubuntu Trucchi +## + +import tempfile +import sys +import os + +PYTHON_VERSION = sys.version_info[0:2] + +class NamedTemporaryFile(object): + "Replacement for NamedTemporaryFile compatible with python 2.5" + def __init__(self, mode='w+b', delete=True): + self.delete = delete + if PYTHON_VERSION[0] == 2 and PYTHON_VERSION[1] >= 6: + self.tempfile = tempfile.NamedTemporaryFile(mode=mode, delete=delete) + self.name = self.tempfile.name + else: + # Python < 2.6 doesn't have a delete argument for NamedTemporaryFile + # We have to proceed manually :-\ + self.name = tempfile.mkstemp()[1] + self.tempfile = open(self.name, mode=mode) + + def __del__(self): + self.close() + self.tempfile = None + + def write(self, data): + "Write data to the temporary file" + return self.tempfile.write(data) + + def close(self): + "Close the temporary file and delete it if requested" + ret = self.tempfile.close() + if PYTHON_VERSION[0] == 2 and PYTHON_VERSION[1] < 6 and self.delete: + # Manually deletion of temporary filename + os.remove(self.name) + return ret diff --git a/gespeaker.glade.h b/gespeaker.glade.h new file mode 100644 index 0000000..58d88bd --- /dev/null +++ b/gespeaker.glade.h @@ -0,0 +1,14 @@ +char *s = N_("Insert text to play"); +char *s = N_("Settings"); +char *s = N_("Dela_y:"); +char *s = N_("Fem_ale"); +char *s = N_("P_itch:"); +char *s = N_("Spee_d:"); +char *s = N_("Voice:"); +char *s = N_("Welcome in Gespeaker"); +char *s = N_("_Edit"); +char *s = N_("_File"); +char *s = N_("_Help"); +char *s = N_("_Language:"); +char *s = N_("_Male"); +char *s = N_("_Volume:"); diff --git a/gespeaker.svg b/gespeaker.svg new file mode 100644 index 0000000..8fd422e --- /dev/null +++ b/gespeaker.svg @@ -0,0 +1,553 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/locale/en_US.po b/locale/en_US.po new file mode 100644 index 0000000..ae8b1f1 --- /dev/null +++ b/locale/en_US.po @@ -0,0 +1,110 @@ +# gespeaker - A GTK frontend for espeak +# Copyright (C) 2009 Muflone Ubuntu Trucchi +# This file is distributed under the GPL v2 license (see copyright file). +# Muflone , 2009. +# English translations for gespeaker package. +# +msgid "" +msgstr "" +"Project-Id-Version: Gespeaker 0.4\n" +"Report-Msgid-Bugs-To: Muflone \n" +"POT-Creation-Date: 2009-06-20 12:09+0200\n" +"PO-Revision-Date: 2009-06-20 12:13+0200\n" +"Last-Translator: Muflone \n" +"Language-Team: English\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: gespeaker.glade.h:1 +msgid "Insert text to play" +msgstr "Insert text to play" + +#: gespeaker.glade.h:2 +msgid "Settings" +msgstr "Settings" + +#: gespeaker.glade.h:3 +msgid "Dela_y:" +msgstr "Dela_y:" + +#: gespeaker.glade.h:4 +msgid "Fem_ale" +msgstr "Fem_ale" + +#: gespeaker.glade.h:5 +msgid "P_itch:" +msgstr "P_itch:" + +#: gespeaker.glade.h:6 +msgid "Spee_d:" +msgstr "Spee_d:" + +#: gespeaker.glade.h:7 +msgid "Voice:" +msgstr "Voice:" + +#: gespeaker.glade.h:8 +msgid "Welcome in Gespeaker" +msgstr "Welcome in Gespeaker" + +#: gespeaker.glade.h:9 +msgid "_Edit" +msgstr "_Edit" + +#: gespeaker.glade.h:10 +msgid "_File" +msgstr "_File" + +#: gespeaker.glade.h:11 +msgid "_Help" +msgstr "_Help" + +#: gespeaker.glade.h:12 +msgid "_Language:" +msgstr "_Language:" + +#: gespeaker.glade.h:13 +msgid "_Male" +msgstr "_Male" + +#: gespeaker.glade.h:14 +msgid "_Volume:" +msgstr "_Volume:" + +#: gespeakerUI.py:101 +msgid "default language" +msgstr "english" + +#: gespeakerUI.py:122 +msgid "Do you want to delete the current text?" +msgstr "Do you want to delete the current text?" + +#: gespeakerUI.py:133 +msgid "Please select the file to open" +msgstr "Please select the file to open" + +#: gespeakerUI.py:143 gespeakerUI.py:150 +msgid "Error opening the file" +msgstr "Error opening the file" + +#: gespeakerUI.py:157 +msgid "Please select where to save the file" +msgstr "Please select where to save the file" + +#: gespeakerUI.py:168 gespeakerUI.py:175 +msgid "Error saving the file" +msgstr "Error saving the file" + +#: gespeakerUI.py:183 +msgid "Do you want to reset the default settings?" +msgstr "Do you want to reset the default settings?" + +#: gespeakerUI.py:204 +msgid "A GTK frontend for espeak" +msgstr "A GTK frontend for espeak" + +#: gespeakerUI.py:210 +msgid "translation" +msgstr "English translation by Muflone " diff --git a/locale/fr.po b/locale/fr.po new file mode 100644 index 0000000..859542d --- /dev/null +++ b/locale/fr.po @@ -0,0 +1,110 @@ +# gespeaker - A GTK frontend for espeak +# Copyright (C) 2009 Muflone Ubuntu Trucchi +# This file is distributed under the GPL v2 license (see copyright file). +# Muflone , 2009. +# French translation for gespeaker +# +msgid "" +msgstr "" +"Project-Id-Version: Gespeaker 0.4\n" +"Report-Msgid-Bugs-To: Muflone \n" +"POT-Creation-Date: 2009-06-20 12:09+0200\n" +"PO-Revision-Date: 2009-06-20 12:13+0200\n" +"Last-Translator: Emmanuel \n" +"Language-Team: French\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: gespeaker.glade.h:1 +msgid "Insert text to play" +msgstr "" + +#: gespeaker.glade.h:2 +msgid "Settings" +msgstr "" + +#: gespeaker.glade.h:3 +msgid "Dela_y:" +msgstr "" + +#: gespeaker.glade.h:4 +msgid "Fem_ale" +msgstr "" + +#: gespeaker.glade.h:5 +msgid "P_itch:" +msgstr "" + +#: gespeaker.glade.h:6 +msgid "Spee_d:" +msgstr "" + +#: gespeaker.glade.h:7 +msgid "Voice:" +msgstr "" + +#: gespeaker.glade.h:8 +msgid "Welcome in Gespeaker" +msgstr "" + +#: gespeaker.glade.h:9 +msgid "_Edit" +msgstr "" + +#: gespeaker.glade.h:10 +msgid "_File" +msgstr "" + +#: gespeaker.glade.h:11 +msgid "_Help" +msgstr "" + +#: gespeaker.glade.h:12 +msgid "_Language:" +msgstr "" + +#: gespeaker.glade.h:13 +msgid "_Male" +msgstr "" + +#: gespeaker.glade.h:14 +msgid "_Volume:" +msgstr "" + +#: gespeakerUI.py:101 +msgid "default language" +msgstr "french" + +#: gespeakerUI.py:122 +msgid "Do you want to delete the current text?" +msgstr "" + +#: gespeakerUI.py:133 +msgid "Please select the file to open" +msgstr "" + +#: gespeakerUI.py:143 gespeakerUI.py:150 +msgid "Error opening the file" +msgstr "" + +#: gespeakerUI.py:157 +msgid "Please select where to save the file" +msgstr "" + +#: gespeakerUI.py:168 gespeakerUI.py:175 +msgid "Error saving the file" +msgstr "" + +#: gespeakerUI.py:183 +msgid "Do you want to reset the default settings?" +msgstr "" + +#: gespeakerUI.py:204 +msgid "A GTK frontend for espeak" +msgstr "" + +#: gespeakerUI.py:210 +msgid "translation" +msgstr "" diff --git a/locale/fr/LC_MESSAGES/gespeaker.mo b/locale/fr/LC_MESSAGES/gespeaker.mo new file mode 100644 index 0000000..f43395d Binary files /dev/null and b/locale/fr/LC_MESSAGES/gespeaker.mo differ diff --git a/locale/gespeaker.pot b/locale/gespeaker.pot new file mode 100644 index 0000000..df2fe24 --- /dev/null +++ b/locale/gespeaker.pot @@ -0,0 +1,110 @@ +# gespeaker - A GTK frontend for espeak +# Copyright (C) 2009 Muflone Ubuntu Trucchi +# This file is distributed under the GPL v2 license (see copyright file). +# Muflone , 2009. +# X translation for gespeaker +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Gespeaker 0.4\n" +"Report-Msgid-Bugs-To: Muflone \n" +"POT-Creation-Date: 2009-06-20 12:09+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: gespeaker.glade.h:1 +msgid "Insert text to play" +msgstr "" + +#: gespeaker.glade.h:2 +msgid "Settings" +msgstr "" + +#: gespeaker.glade.h:3 +msgid "Dela_y:" +msgstr "" + +#: gespeaker.glade.h:4 +msgid "Fem_ale" +msgstr "" + +#: gespeaker.glade.h:5 +msgid "P_itch:" +msgstr "" + +#: gespeaker.glade.h:6 +msgid "Spee_d:" +msgstr "" + +#: gespeaker.glade.h:7 +msgid "Voice:" +msgstr "" + +#: gespeaker.glade.h:8 +msgid "Welcome in Gespeaker" +msgstr "" + +#: gespeaker.glade.h:9 +msgid "_Edit" +msgstr "" + +#: gespeaker.glade.h:10 +msgid "_File" +msgstr "" + +#: gespeaker.glade.h:11 +msgid "_Help" +msgstr "" + +#: gespeaker.glade.h:12 +msgid "_Language:" +msgstr "" + +#: gespeaker.glade.h:13 +msgid "_Male" +msgstr "" + +#: gespeaker.glade.h:14 +msgid "_Volume:" +msgstr "" + +#: gespeakerUI.py:101 +msgid "default language" +msgstr "" + +#: gespeakerUI.py:122 +msgid "Do you want to delete the current text?" +msgstr "" + +#: gespeakerUI.py:133 +msgid "Please select the file to open" +msgstr "" + +#: gespeakerUI.py:143 gespeakerUI.py:150 +msgid "Error opening the file" +msgstr "" + +#: gespeakerUI.py:157 +msgid "Please select where to save the file" +msgstr "" + +#: gespeakerUI.py:168 gespeakerUI.py:175 +msgid "Error saving the file" +msgstr "" + +#: gespeakerUI.py:183 +msgid "Do you want to reset the default settings?" +msgstr "" + +#: gespeakerUI.py:204 +msgid "A GTK frontend for espeak" +msgstr "" + +#: gespeakerUI.py:210 +msgid "translation" +msgstr "" diff --git a/locale/i18n-3.sh b/locale/i18n-3.sh new file mode 100755 index 0000000..9a1a339 --- /dev/null +++ b/locale/i18n-3.sh @@ -0,0 +1,11 @@ +#!/bin/bash +for file in *.po; +do ( + filemo=$(basename $file .po) + if [ -d $filemo ]; + then rm -r $filemo + fi + mkdir -p $filemo/LC_MESSAGES + msgfmt --output-file=$filemo/LC_MESSAGES/gespeaker.mo $file +) +done \ No newline at end of file diff --git a/locale/it.po b/locale/it.po new file mode 100644 index 0000000..23017c7 --- /dev/null +++ b/locale/it.po @@ -0,0 +1,111 @@ +# gespeaker - A GTK frontend for espeak +# Copyright (C) 2009 Muflone Ubuntu Trucchi +# This file is distributed under the GPL v2 license (see copyright file). +# Muflone , 2009. +# Italian translation for gespeaker +# +msgid "" +msgstr "" +"Project-Id-Version: Gespeaker 0.4\n" +"Report-Msgid-Bugs-To: Muflone \n" +"POT-Creation-Date: 2009-06-20 12:09+0200\n" +"PO-Revision-Date: 2009-06-20 12:13+0200\n" +"Last-Translator: Muflone \n" +"Language-Team: Italian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: gespeaker.glade.h:1 +msgid "Insert text to play" +msgstr "Inserisci il testo da riprodurre" + +#: gespeaker.glade.h:2 +msgid "Settings" +msgstr "Impostazioni" + +#: gespeaker.glade.h:3 +msgid "Dela_y:" +msgstr "Ritar_do:" + +#: gespeaker.glade.h:4 +msgid "Fem_ale" +msgstr "F_emminile" + +#: gespeaker.glade.h:5 +msgid "P_itch:" +msgstr "_Tonalità:" + +#: gespeaker.glade.h:6 +msgid "Spee_d:" +msgstr "_Velocità:" + +#: gespeaker.glade.h:7 +msgid "Voice:" +msgstr "Voce:" + +#: gespeaker.glade.h:8 +msgid "Welcome in Gespeaker" +msgstr "Benvenuto in Gespeaker" + +#: gespeaker.glade.h:9 +msgid "_Edit" +msgstr "_Modifica" + +#: gespeaker.glade.h:10 +msgid "_File" +msgstr "_File" + +#: gespeaker.glade.h:11 +msgid "_Help" +msgstr "A_iuto" + +#: gespeaker.glade.h:12 +msgid "_Language:" +msgstr "_Lingua:" + +#: gespeaker.glade.h:13 +msgid "_Male" +msgstr "M_aschile" + +#: gespeaker.glade.h:14 +msgid "_Volume:" +msgstr "V_olume:" + +#: gespeakerUI.py:101 +msgid "default language" +msgstr "italian" + +#: gespeakerUI.py:122 +msgid "Do you want to delete the current text?" +msgstr "Vuoi cancellare il testo corrente?" + +#: gespeakerUI.py:133 +msgid "Please select the file to open" +msgstr "Scegli il file da aprire" + +#: gespeakerUI.py:143 gespeakerUI.py:150 +msgid "Error opening the file" +msgstr "Errore nell'apertura del file" + +#: gespeakerUI.py:157 +msgid "Please select where to save the file" +msgstr "Scegli dove salvare il file" + +#: gespeakerUI.py:168 gespeakerUI.py:175 +msgid "Error saving the file" +msgstr "Errore nel salvataggio del file" + +#: gespeakerUI.py:183 +msgid "Do you want to reset the default settings?" +msgstr "Vuoi ripristinare le impostazioni predefinite?" + +#: gespeakerUI.py:204 +msgid "A GTK frontend for espeak" +msgstr "Un'interfaccia in GTK per espeak" + +#: gespeakerUI.py:210 +msgid "translation" +msgstr "Traduzione italiana di Muflone " +