mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
599e1f6f57
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
124 lines
5.1 KiB
Diff
124 lines
5.1 KiB
Diff
diff --git a/README b/README
|
|
index c540542..87bb3d8 100644
|
|
--- a/README
|
|
+++ b/README
|
|
@@ -1,5 +1,5 @@
|
|
PicoSpeaker
|
|
-Written by Kyle
|
|
+Orginally Written by Kyle and forked by shilber01 to work with SNIPS (snips.ai)
|
|
|
|
DESCRIPTION
|
|
|
|
diff --git a/pico.patch b/pico.patch
|
|
new file mode 100644
|
|
index 0000000..0e2680a
|
|
--- /dev/null
|
|
+++ b/pico.patch
|
|
@@ -0,0 +1,19 @@
|
|
+--- picospeaker.bak 2018-08-27 22:03:05.000000000 +0200
|
|
++++ picospeaker 2018-08-27 23:49:35.289440981 +0200
|
|
+@@ -59,8 +59,16 @@
|
|
+ exit(0)
|
|
+ elif ( argv[opt] == '-l' ) or ( argv[opt] == '--language' ):
|
|
+ languages = ('en-US', 'en-GB', 'de-DE', 'es-ES', 'fr-FR', 'it-IT')
|
|
++ lang_map = {
|
|
++ 'en': 'en-US',
|
|
++ 'de': 'de-DE',
|
|
++ 'es': 'es-ES',
|
|
++ 'fr': 'fr-FR',
|
|
++ 'it': 'it-IT'}
|
|
+ if ( argv[opt+1] in languages ):
|
|
+ settings['language'] = argv[opt+1]
|
|
++ elif ( argv[opt+1] in lang_map.keys() ):
|
|
++ settings['language'] = lang_map[argv[opt+1]]
|
|
+ else:
|
|
+ stderr.write('Language ' + argv[opt+1] + ' is currently not available.\n')
|
|
+ stderr.write('Available languages are ' + ', '.join(languages[:-1]) + ' and ' + languages[-1] + '.\n')
|
|
\ No newline at end of file
|
|
diff --git a/picospeaker b/picospeaker
|
|
index 6b49d34..b9f91c3 100755
|
|
--- a/picospeaker
|
|
+++ b/picospeaker
|
|
@@ -14,8 +14,8 @@ from time import sleep
|
|
|
|
# help and version tuples
|
|
version = (
|
|
- 'PicoSpeaker 0.6.2',
|
|
- 'Written by Kyle',
|
|
+ 'PicoSpeaker 0.6.2-1',
|
|
+ 'Written by Kyle,forked by shilbert01',
|
|
'This program is free and unencumbered software released into the public domain.',
|
|
'See the included UNLICENSE file for details.')
|
|
help = (
|
|
@@ -59,8 +59,16 @@ def parse ():
|
|
exit(0)
|
|
elif ( argv[opt] == '-l' ) or ( argv[opt] == '--language' ):
|
|
languages = ('en-US', 'en-GB', 'de-DE', 'es-ES', 'fr-FR', 'it-IT')
|
|
+ lang_map = {
|
|
+ 'en': 'en-US',
|
|
+ 'de': 'de-DE',
|
|
+ 'es': 'es-ES',
|
|
+ 'fr': 'fr-FR',
|
|
+ 'it': 'it-IT'}
|
|
if ( argv[opt+1] in languages ):
|
|
settings['language'] = argv[opt+1]
|
|
+ elif ( argv[opt+1] in lang_map.keys() ):
|
|
+ settings['language'] = lang_map[argv[opt+1]]
|
|
else:
|
|
stderr.write('Language ' + argv[opt+1] + ' is currently not available.\n')
|
|
stderr.write('Available languages are ' + ', '.join(languages[:-1]) + ' and ' + languages[-1] + '.\n')
|
|
@@ -117,7 +125,7 @@ def parse ():
|
|
continue
|
|
else:
|
|
# First, die with an error if compression and/or type are set but no output file is specified
|
|
- if ( ( settings.has_key('compression') ) or ( settings.has_key('filetype') ) ) and not ( settings.has_key('output') ):
|
|
+ if ( ( 'compression' in settings ) or ( 'filetype' in settings ) ) and ( 'output' not in settings ):
|
|
stderr.write('You must specify the output file.\n')
|
|
exit(1)
|
|
# Now the text can be added to the settings object and the loop can be broken
|
|
@@ -128,7 +136,7 @@ def parse ():
|
|
def tts():
|
|
'convert text to speech data and store it in a temporary file using the pico2wave utility from SVox Pico'
|
|
command = ['pico2wave', '-w', temp]
|
|
- if ( settings.has_key('language') ): command += ['-l', settings['language']]
|
|
+ if ( 'language' in settings ): command += ['-l', settings['language']]
|
|
command += ['--', settings['text']]
|
|
try:
|
|
call(command)
|
|
@@ -139,16 +147,16 @@ def tts():
|
|
def speaker():
|
|
'speaks the text, or saves it if an output file was specified on the command line'
|
|
command = ['play', '-q']
|
|
- if ( settings.has_key('volume') ): command += ['-v', settings['volume']]
|
|
+ if ( 'volume' in settings ): command += ['-v', settings['volume']]
|
|
command.append(temp)
|
|
- if ( settings.has_key('output') ):
|
|
+ if ( 'output' in settings ):
|
|
command[0] = 'sox'
|
|
del command[1]
|
|
- if ( settings.has_key('filetype') ): command += ['-t', settings['filetype']]
|
|
- if ( settings.has_key('compression') ): command += ['-C', settings['compression']]
|
|
+ if ( 'filetype' in settings ): command += ['-t', settings['filetype']]
|
|
+ if ( 'compression' in settings ): command += ['-C', settings['compression']]
|
|
command.append(settings['output'])
|
|
- if ( settings.has_key('pitch') ): command += ['gain', '-0.15', 'pitch', str(float(settings['pitch'])*100)]
|
|
- if ( settings.has_key('rate') ): command += ['gain', '-0.1', 'tempo', '-s', str(1+float(settings['rate'])/100)]
|
|
+ if ( 'pitch' in settings ): command += ['gain', '-0.15', 'pitch', str(float(settings['pitch'])*100)]
|
|
+ if ( 'rate' in settings ): command += ['gain', '-0.1', 'tempo', '-s', str(1+float(settings['rate'])/100)]
|
|
speak = Popen(command)
|
|
sleep(0.1) # the temp file should be open by now
|
|
# The temp file can be removed as soon as it is opened in case PicoSpeaker is killed while speaking
|
|
@@ -157,11 +165,11 @@ def speaker():
|
|
|
|
try:
|
|
settings = parse()
|
|
- if ( not settings.has_key('text') ):
|
|
+ if ( 'text' not in settings ):
|
|
settings['text'] = stdin.read()
|
|
tts()
|
|
speaker()
|
|
except KeyboardInterrupt:
|
|
stderr.write('Keyboard interrupt received. Cleaning up.\n')
|
|
- try: remove(temp)
|
|
+ try: remove(temp) # The temp file may not have been removed yet
|
|
except OSError: pass # The file doesn't exist and therefore doesn't need to be removed
|