Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sound/tts
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2015-10-15 16:30:31 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2015-10-15 16:30:31 +0300
commit4bc843b632142cc5ea52492cf0829fe010316bfc (patch)
tree8ed3782146da5ca20918a2b0b4047002f74449bc /sound/tts
parentb558d2449aff06613196785a42a0ac68358dbd4e (diff)
Moving TTS sound scripts from sound/tts to tools/sound.
Diffstat (limited to 'sound/tts')
-rwxr-xr-xsound/tts/generate_sound_localizations.sh27
-rwxr-xr-xsound/tts/languages.py67
-rwxr-xr-xsound/tts/sound_csv_to_sound_txt.py77
3 files changed, 0 insertions, 171 deletions
diff --git a/sound/tts/generate_sound_localizations.sh b/sound/tts/generate_sound_localizations.sh
deleted file mode 100755
index cc2ef4e536..0000000000
--- a/sound/tts/generate_sound_localizations.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-# When text resources for voice notification are updated this script shall be launched
-# to regenerate sound_strings.zip. Then sound_strings.zip will be used by the application for TTS systems.
-
-set -e -u -x
-
-MY_PATH="`dirname \"$0\"`" # relative
-MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
-
-readonly SOUND_TMP_DIR=$MY_PATH/../../../sound-tmp
-
-rm -f $MY_PATH/sound_strings.zip
-rm -rf $SOUND_TMP_DIR
-mkdir $SOUND_TMP_DIR
-
-python $MY_PATH/sound_csv_to_sound_txt.py $MY_PATH/sound.csv $MY_PATH/sound.txt $MY_PATH/languages.txt
-
-mkdir $SOUND_TMP_DIR/json
-python $MY_PATH/languages.py $MY_PATH/languages.txt $MY_PATH/languages.hpp $SOUND_TMP_DIR/json/
-$MY_PATH/../../tools/twine/twine --format jquery generate-all-string-files $MY_PATH/sound.txt $SOUND_TMP_DIR/json
-
-readonly SOUND_OUTPUT_DIR=$MY_PATH/../../data/sound-strings/
-if [ ! -d $SOUND_OUTPUT_DIR ]; then
- mkdir $SOUND_OUTPUT_DIR
-fi
-cp -R $SOUND_TMP_DIR/json/ $SOUND_OUTPUT_DIR
diff --git a/sound/tts/languages.py b/sound/tts/languages.py
deleted file mode 100755
index 3a9b164584..0000000000
--- a/sound/tts/languages.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/python
-
-from __future__ import print_function
-from optparse import OptionParser
-
-import os
-
-languages_hpp_template = """\
-#pragma once
-
-#include "std/array.hpp"
-#include "std/string.hpp"
-
-// This file is autogenerated while exporting sounds.csv from the google table.
-// It contains the list of languages which can be used by TTS.
-// It shall be included to Android(jni) and iOS part to get the languages list.
-
-namespace routing
-{{
-namespace turns
-{{
-namespace sound
-{{
-array<string, {lang_list_size}> const kLanguageList =
-{{{{
-{lang_list}
-}}}};
-}} // namespace sound
-}} // namespace turns
-}} // namespace routing
-"""
-
-def parse_args():
- opt_parser = OptionParser(usage="This tool creates directories for languages for twine."
- + "All directory names shall be listed in languages file with space separator.\n"
- + "Example: python %prog path_to_language.txt path_to_languages.hpp path_to_dir_with_json_files",
- version="%prog 1.0")
-
- (options, args) = opt_parser.parse_args()
-
- if len(args) != 3:
- opt_parser.error("Wrong number of arguments.")
- return args
-
-def make_language_dirs(langs_name, json_dir_name):
- print ("Creating directories for languages in json.")
- with open(langs_name, "r") as langs_file:
- for lang in langs_file.read().split():
- new_dir = os.path.join(json_dir_name, lang + ".json")
- if not os.path.exists(new_dir):
- os.makedirs(new_dir)
-
-def make_languages_hpp(langs_name, hpp_name):
- print ("Creating {fine_name}".format(fine_name = hpp_name))
- with open(langs_name, 'r') as langs_file:
- languages_list = langs_file.read().split()
- lang_str = ",\n".join([" \"{}\"".format(language) for language in languages_list])
- with open(hpp_name, "w") as hpp_file:
- hpp_file.write(languages_hpp_template.format(lang_list_size = len(languages_list), lang_list = lang_str))
-
-def run():
- langs_name, langs_hpp_name, json_dir_name = parse_args()
- make_language_dirs(langs_name, json_dir_name)
- make_languages_hpp(langs_name, langs_hpp_name)
-
-if __name__ == "__main__":
- run()
diff --git a/sound/tts/sound_csv_to_sound_txt.py b/sound/tts/sound_csv_to_sound_txt.py
deleted file mode 100755
index 4297d7bfef..0000000000
--- a/sound/tts/sound_csv_to_sound_txt.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/python
-
-from __future__ import print_function
-from optparse import OptionParser
-
-import csv
-import os.path
-
-# The number of a column in the google table which contains ids of sound strings.
-ID_COLUMN = 1
-# MIN_PROCESSED_COLUMN and MAX_PROCESSED_COLUMN define the range of column in google table
-# which will be processed by the script. See the following link for the google table:
-# https://docs.google.com/spreadsheets/d/1gJsSzFpp2B3xnSx-RjjQ3Do66lQDhCxtfEnQo7Vrkw0/edit#gid=150382014
-MIN_PROCESSED_COLUMN = 2
-MAX_PROCESSED_COLUMN = 31
-
-
-def parse_args():
- opt_parser = OptionParser(usage="It's a tool for converting text voice messages from csv to twine input format."
- + "As a source shall be taken a csv file from\n"
- + "https://docs.google.com/spreadsheets/d/1gJsSzFpp2B3xnSx-RjjQ3Do66lQDhCxtfEnQo7Vrkw0/edit#gid=150382014\n"
- + "The output shall be put to omim/sound/tts/sound.txt. As another output file the tool generates languages.txt."
- + "languages.txt contains all available languages in csv.\n"
- + "Notice. The script replaces all non-breaking spaces with spaces.\n"
- + "Example: python %prog path_to_sound.csv path_to_sound.txt path_to_languages.txt",
- version="%prog 1.0")
-
- (options, args) = opt_parser.parse_args()
-
- if len(args) != 3:
- opt_parser.error("Wrong number of arguments.")
- return args
-
-
-def nbsp_to_spaces(str):
- return str.replace('\xc2\xa0', ' ')
-
-
-def run():
- csv_name, twine_name, languages_name = parse_args()
-
- print("Converting sound.csv to sound.txt (input of twine)")
- if not os.path.isfile(csv_name):
- print("Error. CSV file not found. Please check the usage.\n")
- return
-
- with open(twine_name, 'w') as twine_file:
- with open(csv_name, 'rb') as csv_file:
- twine_file.write('[[sound]]\n')
- csv_reader = csv.reader(csv_file, delimiter=',', quotechar='\n')
-
- languages = dict()
- csv_reader.next()
-# A row with language names (like en, ru and so on) is located on the second line.
- language_row = csv_reader.next()
- with open(languages_name, 'w') as languages_file:
- for idx, lang in enumerate(language_row):
- if (MIN_PROCESSED_COLUMN <= idx < MAX_PROCESSED_COLUMN and lang):
- languages[idx] = lang
- languages_file.write(lang + ' ')
-
- csv_reader.next()
-# Translation follows starting from the 4th line in the table.
- for row in csv_reader:
- if row[ID_COLUMN]:
- twine_file.write(' [{section}]\n'.format(section = nbsp_to_spaces(row[ID_COLUMN])))
- for column_idx, translation in enumerate(row):
- if (MIN_PROCESSED_COLUMN <= column_idx < MAX_PROCESSED_COLUMN and column_idx in languages.keys()):
- twine_file.write(' {lang} = {trans}\n'.format(lang = languages[column_idx],
- trans = nbsp_to_spaces(translation)))
- twine_file.write('\n')
-
- print('Done. Check {twine} and {lang} for the result.\n'.format(twine = twine_name, lang = languages_name))
-
-
-if __name__ == "__main__":
- run()