Now uses the external libopenui
This commit is contained in:
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from charset import get_chars, special_chars, extra_chars
|
||||
|
||||
|
||||
class FontBitmap:
|
||||
def __init__(self, chars, font_size, font_name, cn_font_name, foreground, background):
|
||||
self.chars = chars
|
||||
self.font_size = font_size
|
||||
self.foreground = foreground
|
||||
self.background = background
|
||||
|
||||
self.font, self.font_offset = self.load_font(font_name)
|
||||
self.cn_font, self.cn_font_offset = self.load_font(cn_font_name)
|
||||
self.extra_bitmap = self.load_extra_bitmap()
|
||||
|
||||
def load_extra_bitmap(self):
|
||||
try:
|
||||
extra_filename = 'fonts/extra_%dpx.png' % self.font_size
|
||||
extra_image = Image.open(extra_filename)
|
||||
return extra_image.convert('RGB')
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
def load_font(self, font_name):
|
||||
# print(font_name)
|
||||
font_name, font_offset = font_name.split(":")
|
||||
for ext in (".ttf", ".otf"):
|
||||
path = 'fonts/' + font_name + ext
|
||||
if os.path.exists(path):
|
||||
return ImageFont.truetype(path, self.font_size), int(font_offset)
|
||||
|
||||
def get_char_width(self, c):
|
||||
if c in extra_chars:
|
||||
if self.extra_bitmap:
|
||||
# Extra characters 16px
|
||||
# if fontsize == 16:
|
||||
if extra_chars.index(c) < 9:
|
||||
return 13
|
||||
else:
|
||||
return 15
|
||||
else:
|
||||
return 0
|
||||
elif c == " ":
|
||||
return 4
|
||||
elif c in special_chars["cn"]:
|
||||
w, h = self.cn_font.getsize(c)
|
||||
return w + 1
|
||||
else:
|
||||
w, h = self.font.getsize(c)
|
||||
return w + 1
|
||||
|
||||
def get_width(self):
|
||||
width = 0
|
||||
for c in self.chars:
|
||||
width += self.get_char_width(c)
|
||||
return width
|
||||
|
||||
def generate(self, filename, generate_coords_file=True):
|
||||
coords = [self.font_size + 4]
|
||||
width = self.get_width()
|
||||
image = Image.new('RGB', (width, self.font_size + 4), self.background)
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
width = 0
|
||||
for c in self.chars:
|
||||
coords.append(width)
|
||||
|
||||
if c in extra_chars:
|
||||
if self.extra_bitmap and c == extra_chars[0]:
|
||||
if self.font_size == 16:
|
||||
offset = 1
|
||||
else:
|
||||
offset = self.font_size % 2
|
||||
image.paste(self.extra_bitmap.copy(), (width, offset))
|
||||
elif c == " ":
|
||||
pass
|
||||
elif c in special_chars["cn"]:
|
||||
draw.text((width + 1, self.cn_font_offset), c, fill=self.foreground, font=self.cn_font)
|
||||
else:
|
||||
draw.text((width + 1, self.font_offset), c, fill=self.foreground, font=self.font)
|
||||
|
||||
width += self.get_char_width(c)
|
||||
|
||||
coords.append(width)
|
||||
|
||||
image.save(filename + ".png")
|
||||
if generate_coords_file:
|
||||
with open(filename + ".specs", "w") as f:
|
||||
f.write(",".join(str(tmp) for tmp in coords))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Builder for OpenTX font files")
|
||||
parser.add_argument('--output', help="Output file name")
|
||||
parser.add_argument('--subset', help="Subset", default="all")
|
||||
parser.add_argument('--size', type=int, help="Font size")
|
||||
parser.add_argument('--font', help="Font name")
|
||||
parser.add_argument('--cn-font', help="Chinese font name")
|
||||
args = parser.parse_args()
|
||||
|
||||
font = FontBitmap(get_chars(args.subset), args.size, args.font, args.cn_font, (0, 0, 0), (255, 255, 255))
|
||||
font.generate(args.output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# used ? Δ~\n\t
|
||||
|
||||
import os
|
||||
|
||||
standard_chars = "!#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz~|≥"
|
||||
|
||||
extra_chars = "".join([chr(0x10000+i) for i in range(21)])
|
||||
|
||||
|
||||
def chinese_chars():
|
||||
charset = set()
|
||||
tools_path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(os.path.join(tools_path, "../radio/src/translations/cn.h.txt")) as f:
|
||||
data = f.read()
|
||||
for c in data:
|
||||
if 0x4E00 <= ord(c) <= 0x9FFF:
|
||||
charset.add(c)
|
||||
# print(ord(c))
|
||||
result = list(charset)
|
||||
result.sort()
|
||||
return result
|
||||
|
||||
|
||||
special_chars = {
|
||||
"en": "",
|
||||
"fr": "éèàîç",
|
||||
"de": "ÄäÖöÜüß",
|
||||
"cz": "ěščřžýáíéňóůúďťĚŠČŘŽÝÁÍÉŇÓÚŮĎŤ",
|
||||
"nl": "",
|
||||
"es": "Ññ",
|
||||
"fi": "åäöÅÄÖ",
|
||||
"it": "àù",
|
||||
"pl": "ąćęłńóśżźĄĆĘŁŃÓŚŻŹ",
|
||||
"pt": "ÁáÂâÃãÀàÇçÉéÊêÍíÓóÔôÕõÚú",
|
||||
"se": "åäöÅÄÖ",
|
||||
"cn": "".join(chinese_chars())
|
||||
}
|
||||
|
||||
subset_lowercase = {
|
||||
"Č": "č",
|
||||
"Ě": "ě",
|
||||
"Š": "š",
|
||||
"Ú": "ú",
|
||||
"Ů": "ů",
|
||||
"Ž": "ž"
|
||||
}
|
||||
|
||||
# print("CN charset: %d symbols" % len(special_chars["cn"]))
|
||||
|
||||
|
||||
def get_chars(subset):
|
||||
result = standard_chars + extra_chars
|
||||
if subset == "all":
|
||||
for key, chars in special_chars.items():
|
||||
result += "".join([char for char in chars if char not in result])
|
||||
else:
|
||||
if subset in special_chars:
|
||||
result += "".join([char for char in special_chars[subset] if char not in subset_lowercase])
|
||||
return result
|
||||
|
||||
|
||||
def get_chars_encoding(subset):
|
||||
result = {}
|
||||
if subset == "all":
|
||||
chars = get_chars(subset)
|
||||
for char in chars:
|
||||
if char in special_chars["cn"]:
|
||||
index = special_chars["cn"].index(char) + 1
|
||||
if index >= 0x100:
|
||||
index += 1
|
||||
result[char] = "\\%03o\\%03o" % (0xFE + ((index >> 8) & 0x01), index & 0xFF)
|
||||
elif char not in standard_chars and char not in extra_chars:
|
||||
result[char] = "\\%03o" % (0xC0 + chars.index(char) - len(standard_chars))
|
||||
else:
|
||||
offset = 128 - len(standard_chars)
|
||||
chars = get_chars(subset)
|
||||
for char in chars:
|
||||
if char not in standard_chars:
|
||||
result[char] = "\\%03o" % (offset + chars.index(char))
|
||||
for upper, lower in subset_lowercase.items():
|
||||
if lower in result:
|
||||
result[upper] = result[lower]
|
||||
return result
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import codecs
|
||||
import sys
|
||||
from charset import special_chars, get_chars_encoding
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Encoder for OpenTX translations')
|
||||
parser.add_argument('input', action="store", help="Input file name")
|
||||
parser.add_argument('output', action="store", help="Output file name")
|
||||
parser.add_argument('language', action="store", help="Two letter language identifier", default=None)
|
||||
parser.add_argument("--reverse", help="Reversed char conversion (from number to char)", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.language != "all" and args.language not in special_chars:
|
||||
parser.error(args.language + ' is not a supported language. Try one of the supported ones: %s' % list(special_chars.keys()))
|
||||
sys.exit()
|
||||
|
||||
# if args.reverse:
|
||||
# for translation in special_chars:
|
||||
# translations[translation] = [(after, before) for (before, after) in translations[translation]]
|
||||
|
||||
# Read the input file into a buffer
|
||||
in_file = codecs.open(args.input, "r", "utf-8")
|
||||
|
||||
# Write the result to a temporary file
|
||||
out_file = codecs.open(args.output, 'w', 'utf-8')
|
||||
|
||||
for line in in_file.readlines():
|
||||
# Do the special chars replacements
|
||||
for before, after in get_chars_encoding(args.language).items():
|
||||
line = line.replace(before, after)
|
||||
if line.startswith("#define ZSTR_"):
|
||||
before = line[32:-2]
|
||||
after = ""
|
||||
for c in before:
|
||||
if ord('A') <= ord(c) <= ord('Z'):
|
||||
c = "\\%03o" % (ord(c) - ord('A') + 1)
|
||||
elif ord('a') <= ord(c) <= ord('z'):
|
||||
c = "\\%03o" % (-ord(c) + ord('a') + 255)
|
||||
elif ord('0') <= ord(c) <= ord('9'):
|
||||
c = "\\%03o" % (ord(c) - ord('0') + 27)
|
||||
after = after + c
|
||||
line = line[:32] + after + line[-2:]
|
||||
out_file.write(line)
|
||||
|
||||
out_file.close()
|
||||
in_file.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
branch=2.3.0
|
||||
docker=nightly23
|
||||
workdir=/home/opentx/nightly23
|
||||
output=/var/www/html/2.3/nightlies
|
||||
version=2.3.0
|
||||
|
||||
echo "Increment nightly index"
|
||||
index=`cat index.txt`
|
||||
index=`expr $index + 1`
|
||||
suffix="N$index"
|
||||
|
||||
cd ${workdir}
|
||||
|
||||
echo "Create on-demand build environment"
|
||||
cp code/radio/util/Dockerfile .
|
||||
docker build -t new-${docker} --build-arg OPENTX_VERSION_SUFFIX=${suffix} .
|
||||
docker rmi -f ${docker} || true
|
||||
docker tag new-${docker} ${docker}
|
||||
docker rmi -f new-${docker}
|
||||
|
||||
echo "Call sdcard generation"
|
||||
code/tools/nightly23/build-sdcard.sh
|
||||
|
||||
echo "Delete companion container in case of previous failed atempt"
|
||||
if [ "$(docker ps -aq -f name=companion)" ]; then
|
||||
docker rm --force companion
|
||||
fi
|
||||
|
||||
echo "Build firmware stamps"
|
||||
docker run -dit --name companion -v /home/opentx/${docker}:/opentx ${docker}
|
||||
docker exec companion sh -c "mkdir -p build && cd build && cmake /opentx/code && cp radio/src/stamp.h /opentx/binaries/stamp-opentx.txt"
|
||||
cp -f ${workdir}/binaries/stamp-opentx.txt ${output}/firmware
|
||||
# These radios are currently not enabled
|
||||
# echo "#define BLOCK \"x10,x12s\"" >> ${output}/firmware/stamp-opentx.txt
|
||||
echo "#define ERROR \"MOVE_TO_RC\"" >> ${output}/firmware/stamp-opentx.txt
|
||||
docker exec companion rm -rf build
|
||||
|
||||
echo "Check if Linux companion is needed"
|
||||
if [ ! -f ${output}/companion/linux/companion23_${version}${suffix}_amd64.deb ]; then
|
||||
echo "Build Linux companion"
|
||||
docker exec companion /opentx/code/tools/build-companion-nightly.sh /opentx/code /opentx/binaries/ ${suffix}
|
||||
cp -f binaries/*.deb ${output}/companion/linux/companion23_${version}${suffix}_amd64.deb
|
||||
fi
|
||||
docker stop companion
|
||||
docker rm companion
|
||||
|
||||
echo "Check if Windows companion is needed"
|
||||
if [ ! -f ${output}/companion/windows/companion-windows-${version}${suffix}.exe ]; then
|
||||
echo "Build Windows companion"
|
||||
cd ${output}/companion/windows
|
||||
wget --tries=1 --read-timeout=6000 -O- http://winbox.open-tx.org/companion-builds/compile23.php?branch=$branch\&suffix=${suffix}
|
||||
wget -O companion-windows-${version}${suffix}.exe http://winbox.open-tx.org/companion-builds/companion-windows-${version}${suffix}.exe
|
||||
chmod -Rf g+w companion-windows-${version}${suffix}.exe
|
||||
fi
|
||||
|
||||
echo "Check if Macosc companion is needed"
|
||||
if [ ! -f ${output}/companion/macosx/opentx-companion-${version}${suffix}.dmg ]; then
|
||||
echo "Build Macosx companion"
|
||||
cd ${output}/companion/macosx
|
||||
wget --tries=1 -qO- http://opentx.blinkt.de:8080/~opentx/build-opentx.py?branch=${branch}\&suffix=${suffix}
|
||||
wget -O opentx-companion-${version}${suffix}.dmg http://opentx.blinkt.de:8080/~opentx/builds/opentx-companion-${version}${suffix}.dmg
|
||||
chmod -Rf g+w opentx-companion-${version}${suffix}.dmg
|
||||
fi
|
||||
|
||||
echo "Update Companion stamps"
|
||||
echo "#define VERSION \"${version}${suffix}\"" > ${output}/companion/companion-windows.stamp
|
||||
cp -f ${output}/companion/companion-windows.stamp ${output}/companion/companion-linux.stamp
|
||||
cp -f ${output}/companion/companion-windows.stamp ${output}/companion/companion-macosx.stamp
|
||||
|
||||
echo "Clean binaries It will be hosting built on demand firmware"
|
||||
rm -rf ${workdir}/binaries/*
|
||||
rm -rf ${workdir}/binaries/.lock
|
||||
|
||||
echo "Release $index successfully completed"
|
||||
echo $index > ${workdir}/index.txt
|
||||
@@ -1,76 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
workdir=/home/opentx/nightly23
|
||||
output=/var/www/html/2.3/nightlies
|
||||
|
||||
# Handle opentx.sdcard.version
|
||||
sdcard_version="2.3V"$(grep 'set(SDCARD_REVISION' ${workdir}/code/CMakeLists.txt | grep -o '".*"' | sed 's/"//g')
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/taranis-x9/opentx.sdcard.version
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/taranis-x7/opentx.sdcard.version
|
||||
|
||||
if cmp --silent ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version ${workdir}/opentx.sdcard.version
|
||||
then
|
||||
exit
|
||||
else
|
||||
cd ${workdir}
|
||||
|
||||
# Copy git sdcard data
|
||||
rm -Rf ${workdir}/sdcard
|
||||
cp -r ${workdir}/code/radio/sdcard .
|
||||
|
||||
# Get images for Horus
|
||||
mkdir -p ${workdir}/sdcard/horus/IMAGES
|
||||
cp /home/opentx/horus-bitmaps/* ${workdir}/sdcard/horus/IMAGES/
|
||||
|
||||
|
||||
# Request sound pack generation
|
||||
if [[ ! -d /tmp/SOUNDS/fr ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py en csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/es ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py fr csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/it ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py es csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/de ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py it csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/cz ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py de csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/pl ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py cz csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/ru ]];then
|
||||
${workdir}/code/tools/nightly23/tts.py pt csv files
|
||||
fi
|
||||
${workdir}/code/tools/nightly23/tts.py ru csv psv files
|
||||
|
||||
# Create sdcards.zips for supported platforms
|
||||
mv /tmp/SOUNDS ${workdir}/sdcard/horus/
|
||||
mkdir ${workdir}/sdcard/taranis-x9/SOUNDS
|
||||
mkdir ${workdir}/sdcard/taranis-x7/SOUNDS
|
||||
cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis-x9/
|
||||
cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis-x7/
|
||||
cd ${workdir}/sdcard/horus && zip -r ${output}/sdcard/sdcard-horus-${sdcard_version}.zip *
|
||||
cd ${workdir}/sdcard/taranis-x9 && zip -r ${output}/sdcard/sdcard-taranis-x9-${sdcard_version}.zip *
|
||||
cd ${workdir}/sdcard/taranis-x7 && zip -r ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip *
|
||||
|
||||
# Create symlinks for other radios
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-taranis-xlite-${sdcard_version}.zip
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-taranis-x9lite-${sdcard_version}.zip
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-jumper-t12-${sdcard_version}.zip
|
||||
|
||||
# remove LUA stuff for 9x platform
|
||||
rm -Rf ${workdir}/sdcard/taranis-x7/SCRIPTS
|
||||
rm -Rf ${workdir}/sdcard/taranis-x7/FrSky-utilities
|
||||
cd ${workdir}/sdcard/taranis-x7 && zip -r ${output}/sdcard/sdcard-9xarm-${sdcard_version}.zip *
|
||||
|
||||
rm -Rf ${workdir}/sdcard
|
||||
cp -r ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version ${workdir}
|
||||
fi
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
branch=2.3
|
||||
workdir=/home/opentx/nightly23
|
||||
output=/var/www/html/2.3/nightly
|
||||
|
||||
cd ${workdir}
|
||||
|
||||
# Copy git sdcard data
|
||||
rm -Rf ${workdir}/sdcard
|
||||
cp -r ${workdir}/code/radio/sdcard .
|
||||
|
||||
# Get images for Horus
|
||||
mkdir -p ${workdir}/sdcard/horus/IMAGES
|
||||
cp /home/opentx/horus-bitmaps/* ${workdir}/sdcard/horus/IMAGES/
|
||||
|
||||
# Request sound pack generation
|
||||
wget -qO- http://winbox.open-tx.org/voice-builds/compile23.php?branch=${branch}
|
||||
|
||||
# Get sounds
|
||||
cd sdcard
|
||||
wget http://winbox.open-tx.org/voice-builds/english-irish-taranis.zip
|
||||
wget http://winbox.open-tx.org/voice-builds/english-scottish-taranis.zip
|
||||
wget http://winbox.open-tx.org/voice-builds/english-american-taranis.zip
|
||||
wget http://winbox.open-tx.org/voice-builds/english-australian-taranis.zip
|
||||
wget http://winbox.open-tx.org/voice-builds/french-taranis.zip
|
||||
|
||||
# Prepare the sdcard zip files for Horus
|
||||
unzip english-irish-taranis.zip -d ${workdir}/sdcard/horus
|
||||
mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-irish
|
||||
unzip english-scottish-taranis.zip -d ${workdir}/sdcard/horus
|
||||
mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-scottish
|
||||
unzip english-australian-taranis.zip -d ${workdir}/sdcard/horus
|
||||
mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-australian
|
||||
unzip english-american-taranis -d ${workdir}/sdcard/horus
|
||||
unzip french-taranis.zip -d ${workdir}/sdcard/horus
|
||||
wget -O ${workdir}/sdcard/horus/SOUNDS/en/english.csv http://winbox.open-tx.org/voice-builds/english-american-taranis.csv
|
||||
wget -O ${workdir}/sdcard/horus/SOUNDS/fr/french.csv http://winbox.open-tx.org/voice-builds/french-taranis.csv
|
||||
|
||||
# Duplicate for Taranis and create sdcards.zip
|
||||
mkdir ${workdir}/sdcard/taranis/SOUNDS
|
||||
cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis/
|
||||
rm -f ${workdir}/sdcard/*.zip
|
||||
cd ${workdir}/sdcard/taranis && zip -r ${output}/sdcard/sdcard-taranis.zip *
|
||||
cd ${workdir}/sdcard/horus && zip -r ${output}/sdcard/sdcard-horus.zip *
|
||||
rm -Rf ${workdir}/sdcard
|
||||
@@ -1,154 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
# This script is a modified version to support Linux TTS file generation using PicoTTS
|
||||
|
||||
# Sound pack maintainers (incomplete list) by language alphabetical order
|
||||
# Czech : Martin Hotar
|
||||
# French : Bertrand Songis & André Bernet
|
||||
# English : Rob Thompson & Martin Hotar
|
||||
# German : Romolo Manfredini (Some corrections by Peer)
|
||||
# Italian : Romolo Manfredini
|
||||
# Portuguese : Romolo Manfredini
|
||||
# Spanish : Romolo Manfredini (With the help of Jose Moreno)
|
||||
|
||||
# from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import zipfile
|
||||
from gtts import gTTS
|
||||
from tts_common import *
|
||||
|
||||
|
||||
board = "taranis"
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
SOURCE_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
|
||||
lib_path = os.path.abspath(os.path.join(SOURCE_DIRECTORY, '..', '..', 'radio', 'util'))
|
||||
sys.path.append(lib_path)
|
||||
|
||||
def generate(str, filename):
|
||||
if 0:
|
||||
output = "output.wav"
|
||||
command = 'pico2wave -l=%s -w=%s "%s"' % (voice, output, str)
|
||||
os.system(command.encode('utf-8'))
|
||||
command = "sox %s -r 32000 %s reverse silence 1 0.1 0.1%% reverse" % (output, filename)
|
||||
os.system(command.encode('utf-8'))
|
||||
else:
|
||||
output = u"output.mp3"
|
||||
tts = gTTS(text=str, lang=voice[:2])
|
||||
tts.save(output)
|
||||
command = "sox --norm %s -r 32000 %s tempo 1.2" % (output, filename)
|
||||
os.system(command.encode('utf-8'))
|
||||
command = "rm -f output.mp3"
|
||||
os.system(command.encode('utf-8'))
|
||||
|
||||
################################################################
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "en" in sys.argv:
|
||||
from tts_en import systemSounds, sounds
|
||||
|
||||
directory = "en"
|
||||
voice = "en-US"
|
||||
|
||||
elif "fr" in sys.argv:
|
||||
from tts_fr import systemSounds, sounds
|
||||
|
||||
directory = "fr"
|
||||
voice = "fr-FR"
|
||||
|
||||
elif "it" in sys.argv:
|
||||
from tts_it import systemSounds, sounds
|
||||
|
||||
directory = "it"
|
||||
voice = "it-IT"
|
||||
|
||||
elif "de" in sys.argv:
|
||||
from tts_de import systemSounds, sounds
|
||||
|
||||
directory = "de"
|
||||
voice = "de-DE"
|
||||
|
||||
elif "es" in sys.argv:
|
||||
from tts_es import systemSounds, sounds
|
||||
|
||||
directory = "es"
|
||||
voice = "es-ES"
|
||||
|
||||
elif "cz" in sys.argv:
|
||||
from tts_cz import systemSounds, sounds
|
||||
|
||||
directory = "cz"
|
||||
voice = "cs-CZ"
|
||||
|
||||
elif "ru" in sys.argv:
|
||||
from tts_ru import systemSounds, sounds
|
||||
|
||||
directory = "ru"
|
||||
voice = "ru-RU"
|
||||
|
||||
elif "pt" in sys.argv:
|
||||
from tts_pt import systemSounds, sounds
|
||||
|
||||
directory = "pt"
|
||||
voice = "pt-PT"
|
||||
|
||||
else:
|
||||
print("which language?")
|
||||
exit()
|
||||
|
||||
if "csv" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/SYSTEM/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
with open("%s-%s.csv" % (voice, board), "wb") as csvFile:
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
l = u""
|
||||
if board in ("sky9x", "taranis"):
|
||||
l += u"SOUNDS/%s/SYSTEM;" % directory
|
||||
l += f + u";" + s + u"\n"
|
||||
csvFile.write(l.encode("utf-8"))
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
l = u""
|
||||
if board in ("sky9x", "taranis"):
|
||||
l += u"SOUNDS/%s;" % directory
|
||||
l += f + u";" + s + u"\n"
|
||||
csvFile.write(l.encode("utf-8"))
|
||||
|
||||
if "psv" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
with open("%s-%s.psv" % (voice, board), "wb") as csvFile:
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
l = u"SYSTEM|" + f.replace(".wav", "") + u"|" + s + u"\r\n"
|
||||
csvFile.write(l.encode("windows-1251"))
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
l = u"|" + f.replace(".wav", "") + u"|" + s + u"\r\n"
|
||||
csvFile.write(l.encode("windows-1251"))
|
||||
|
||||
|
||||
if "files" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/SYSTEM/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
generate(s, f)
|
||||
os.chdir("..")
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
generate(s, f)
|
||||
@@ -1,19 +0,0 @@
|
||||
NO_ALTERNATE = 1024
|
||||
PROMPT_CUSTOM_BASE = 256
|
||||
PROMPT_SYSTEM_BASE = 0
|
||||
board = "taranis"
|
||||
|
||||
import sys
|
||||
|
||||
def filename(idx, alternate=0):
|
||||
ext = ".wav"
|
||||
if isinstance(idx, int):
|
||||
result = "%04d%s" % (idx, ext)
|
||||
elif board in ('sky9x', 'taranis'):
|
||||
result = idx + ext
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
branch=2.3.0
|
||||
docker=rc23
|
||||
workdir=/home/opentx/rc23
|
||||
output=/var/www/html/2.3/rc
|
||||
version=2.3.0
|
||||
|
||||
# Increment RC index
|
||||
index=`cat index.txt`
|
||||
index=`expr $index + 1`
|
||||
suffix="RC$index"
|
||||
|
||||
cd ${workdir}
|
||||
|
||||
# Create on-demand build environment
|
||||
cp code/radio/util/Dockerfile .
|
||||
docker build -t new-${docker} --build-arg OPENTX_VERSION_SUFFIX=${suffix} .
|
||||
set +e
|
||||
docker rmi -f ${docker}
|
||||
set -e
|
||||
docker tag new-${docker} ${docker}
|
||||
docker rmi -f new-${docker}
|
||||
|
||||
# Call sdcard generation
|
||||
code/tools/rc23/build-sdcard.sh
|
||||
|
||||
# Build Linux companion
|
||||
docker run -dit --name companion -v /home/opentx/${docker}:/opentx ${docker}
|
||||
docker exec companion sh -c "mkdir -p build && cd build && cmake /opentx/code && cp radio/src/stamp.h /opentx/binaries/stamp-opentx.txt"
|
||||
docker exec companion rm -rf build
|
||||
if [ ! -f ${output}/companion/linux/companion23_${version}${suffix}_amd64.deb ]; then
|
||||
docker exec companion /opentx/code/tools/build-companion-release.sh /opentx/code /opentx/binaries/
|
||||
docker exec companion sh -c "cp /build/radio/src/lua/*.txt /opentx/binaries"
|
||||
cp -f binaries/*.deb ${output}/companion/linux/companion23_${version}${suffix}_amd64.deb
|
||||
cp -f binaries/lua_fields_*.txt ${output}/firmware
|
||||
fi
|
||||
docker stop companion
|
||||
docker rm companion
|
||||
|
||||
# Request companion compilation on Windows
|
||||
if [ ! -f ${output}/companion/windows/companion-windows-${version}${suffix}.exe ]; then
|
||||
cd ${output}/companion/windows
|
||||
wget -qO- http://winbox.open-tx.org/companion-builds/compile23.php?branch=$branch\&suffix=${suffix}
|
||||
wget -O companion-windows-${version}${suffix}.exe http://winbox.open-tx.org/companion-builds/companion-windows-${version}${suffix}.exe
|
||||
chmod -Rf g+w companion-windows-${version}${suffix}.exe
|
||||
fi
|
||||
|
||||
# Request companion compilation on Mac OS X
|
||||
if [ ! -f ${output}/companion/macosx/opentx-companion-${version}${suffix}.dmg ]; then
|
||||
cd ${output}/companion/macosx
|
||||
wget -qO- http://opentx.blinkt.de:8080/~opentx/build-opentx.py?branch=${branch}\&suffix=${suffix}
|
||||
wget -O opentx-companion-${version}${suffix}.dmg http://opentx.blinkt.de:8080/~opentx/builds/opentx-companion-${version}${suffix}.dmg
|
||||
chmod -Rf g+w opentx-companion-${version}${suffix}.dmg
|
||||
fi
|
||||
|
||||
# Update stamps
|
||||
cp -f $workdir/binaries/stamp-opentx.txt ${output}/firmware
|
||||
echo "#define VERSION \"${version}${suffix}\"" > ${output}/companion/companion-windows.stamp
|
||||
cp -f ${output}/companion/companion-windows.stamp ${output}/companion/companion-macosx.stamp
|
||||
cp -f ${output}/companion/companion-windows.stamp ${output}/companion/companion-linux.stamp
|
||||
|
||||
|
||||
# Clean binaries It will be hosting built on demand firmware
|
||||
rm -rf $workdir/binaries/*
|
||||
rm -rf $workdir/binaries/.lock
|
||||
|
||||
# RC is considered as valid ony if we get to that point
|
||||
echo $index > ${workdir}/index.txt
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
workdir=/home/opentx/rc23
|
||||
output=/var/www/html/2.3/rc
|
||||
|
||||
# Handle opentx.sdcard.version
|
||||
sdcard_version="2.3V"$(grep 'set(SDCARD_REVISION' ${workdir}/code/CMakeLists.txt | grep -o '".*"' | sed 's/"//g')
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/taranis-x9/opentx.sdcard.version
|
||||
echo ${sdcard_version} > ${workdir}/code/radio/sdcard/taranis-x7/opentx.sdcard.version
|
||||
|
||||
|
||||
if cmp --silent ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version ${workdir}/opentx.sdcard.version
|
||||
then
|
||||
exit
|
||||
else
|
||||
cd ${workdir}
|
||||
|
||||
# Copy git sdcard data
|
||||
rm -Rf ${workdir}/sdcard
|
||||
cp -r ${workdir}/code/radio/sdcard .
|
||||
|
||||
# Get images for Horus
|
||||
mkdir -p ${workdir}/sdcard/horus/IMAGES
|
||||
cp /home/opentx/horus-bitmaps/* ${workdir}/sdcard/horus/IMAGES/
|
||||
|
||||
|
||||
# Request sound pack generation
|
||||
if [[ ! -d /tmp/SOUNDS/fr ]];then
|
||||
${workdir}/code/tools/rc23/tts.py en csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/es ]];then
|
||||
${workdir}/code/tools/rc23/tts.py fr csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/it ]];then
|
||||
${workdir}/code/tools/rc23/tts.py es csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/de ]];then
|
||||
${workdir}/code/tools/rc23/tts.py it csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/cz ]];then
|
||||
${workdir}/code/tools/rc23/tts.py de csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/pl ]];then
|
||||
${workdir}/code/tools/rc23/tts.py cz csv files
|
||||
fi
|
||||
if [[ ! -d /tmp/SOUNDS/ru ]];then
|
||||
${workdir}/code/tools/rc23/tts.py pt csv files
|
||||
fi
|
||||
${workdir}/code/tools/rc23/tts.py ru csv psv files
|
||||
|
||||
# Create sdcards.zips for supported platforms
|
||||
mv /tmp/SOUNDS ${workdir}/sdcard/horus/
|
||||
mkdir ${workdir}/sdcard/taranis-x9/SOUNDS
|
||||
mkdir ${workdir}/sdcard/taranis-x7/SOUNDS
|
||||
cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis-x9/
|
||||
cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis-x7/
|
||||
cd ${workdir}/sdcard/horus && zip -r ${output}/sdcard/sdcard-horus-${sdcard_version}.zip *
|
||||
cd ${workdir}/sdcard/taranis-x9 && zip -r ${output}/sdcard/sdcard-taranis-x9-${sdcard_version}.zip *
|
||||
cd ${workdir}/sdcard/taranis-x7 && zip -r ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip *
|
||||
|
||||
# Create symlinks for other radios
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-taranis-xlite-${sdcard_version}.zip
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-taranis-x9lite-${sdcard_version}.zip
|
||||
ln -s ${output}/sdcard/sdcard-taranis-x7-${sdcard_version}.zip ${output}/sdcard/sdcard-jumper-t12-${sdcard_version}.zip
|
||||
|
||||
# remove LUA stuff for 9x platform
|
||||
rm -Rf ${workdir}/sdcard/taranis-x7/SCRIPTS
|
||||
rm -Rf ${workdir}/sdcard/taranis-x7/FrSky-utilities
|
||||
cd ${workdir}/sdcard/taranis-x7 && zip -r ${output}/sdcard/sdcard-9xarm-${sdcard_version}.zip *
|
||||
|
||||
rm -Rf ${workdir}/sdcard
|
||||
cp -r ${workdir}/code/radio/sdcard/horus/opentx.sdcard.version ${workdir}
|
||||
fi
|
||||
@@ -1,152 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
# This script is a modified version to support Linux TTS fiel genration using PicoTTS
|
||||
|
||||
# Sound pack maintainers (incomplete list) by language alphabetical order
|
||||
# Czech : Martin Hotar
|
||||
# French : Bertrand Songis & André Bernet
|
||||
# English : Rob Thompson & Martin Hotar
|
||||
# German : Romolo Manfredini (Some corrections by Peer)
|
||||
# Italian : Romolo Manfredini
|
||||
# Portuguese : Romolo Manfredini
|
||||
# Spanish : Romolo Manfredini (With the help of Jose Moreno)
|
||||
|
||||
# from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import zipfile
|
||||
from gtts import gTTS
|
||||
from tts_common import *
|
||||
board = "taranis"
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
SOURCE_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
|
||||
lib_path = os.path.abspath(os.path.join(SOURCE_DIRECTORY, '..', '..', 'radio', 'util'))
|
||||
sys.path.append(lib_path)
|
||||
|
||||
def generate(str, filename):
|
||||
if 0:
|
||||
output = "output.wav"
|
||||
command = 'pico2wave -l=%s -w=%s "%s"' % (voice, output, str)
|
||||
os.system(command.encode('utf-8'))
|
||||
command = "sox %s -r 32000 %s reverse silence 1 0.1 0.1%% reverse" % (output, filename)
|
||||
os.system(command.encode('utf-8'))
|
||||
else:
|
||||
output = u"output.mp3"
|
||||
tts = gTTS(text=str, lang=voice[:2])
|
||||
tts.save(output)
|
||||
command = "sox --norm %s -r 32000 %s tempo 1.2" % (output, filename)
|
||||
os.system(command.encode('utf-8'))
|
||||
command = "rm -f output.mp3"
|
||||
os.system(command.encode('utf-8'))
|
||||
|
||||
################################################################
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "en" in sys.argv:
|
||||
from tts_en import systemSounds, sounds
|
||||
|
||||
directory = "en"
|
||||
voice = "en-US"
|
||||
|
||||
elif "fr" in sys.argv:
|
||||
from tts_fr import systemSounds, sounds
|
||||
|
||||
directory = "fr"
|
||||
voice = "fr-FR"
|
||||
|
||||
elif "it" in sys.argv:
|
||||
from tts_it import systemSounds, sounds
|
||||
|
||||
directory = "it"
|
||||
voice = "it-IT"
|
||||
|
||||
elif "de" in sys.argv:
|
||||
from tts_de import systemSounds, sounds
|
||||
|
||||
directory = "de"
|
||||
voice = "de-DE"
|
||||
|
||||
elif "es" in sys.argv:
|
||||
from tts_es import systemSounds, sounds
|
||||
|
||||
directory = "es"
|
||||
voice = "es-ES"
|
||||
|
||||
elif "cz" in sys.argv:
|
||||
from tts_cz import systemSounds, sounds
|
||||
|
||||
directory = "cz"
|
||||
voice = "cs-CZ"
|
||||
|
||||
elif "ru" in sys.argv:
|
||||
from tts_ru import systemSounds, sounds
|
||||
|
||||
directory = "ru"
|
||||
voice = "ru-RU"
|
||||
|
||||
elif "pt" in sys.argv:
|
||||
from tts_pt import systemSounds, sounds
|
||||
|
||||
directory = "pt"
|
||||
voice = "pt-PT"
|
||||
|
||||
else:
|
||||
print("which language?")
|
||||
exit()
|
||||
|
||||
if "csv" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/SYSTEM/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
with open("%s-%s.csv" % (voice, board), "wb") as csvFile:
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
l = u""
|
||||
if board in ("sky9x", "taranis"):
|
||||
l += u"SOUNDS/%s/SYSTEM;" % directory
|
||||
l += f + u";" + s + u"\n"
|
||||
csvFile.write(l.encode("utf-8"))
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
l = u""
|
||||
if board in ("sky9x", "taranis"):
|
||||
l += u"SOUNDS/%s;" % directory
|
||||
l += f + u";" + s + u"\n"
|
||||
csvFile.write(l.encode("utf-8"))
|
||||
|
||||
if "psv" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
with open("%s-%s.psv" % (voice, board), "wb") as csvFile:
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
l = u"SYSTEM|" + f.replace(".wav", "") + u"|" + s + u"\r\n"
|
||||
csvFile.write(l.encode("windows-1251"))
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
l = u"|" + f.replace(".wav", "") + u"|" + s + u"\r\n"
|
||||
csvFile.write(l.encode("windows-1251"))
|
||||
|
||||
|
||||
if "files" in sys.argv:
|
||||
path = "/tmp/SOUNDS/" + directory + "/SYSTEM/"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.chdir(path)
|
||||
for s, f in systemSounds:
|
||||
if s and f:
|
||||
generate(s, f)
|
||||
os.chdir("..")
|
||||
for s, f in sounds:
|
||||
if s and f:
|
||||
generate(s, f)
|
||||
@@ -1,14 +0,0 @@
|
||||
NO_ALTERNATE = 1024
|
||||
PROMPT_CUSTOM_BASE = 256
|
||||
PROMPT_SYSTEM_BASE = 0
|
||||
board = "taranis"
|
||||
|
||||
import sys
|
||||
|
||||
def filename(idx, alternate=0):
|
||||
ext = ".wav"
|
||||
if isinstance(idx, int):
|
||||
result = "%04d%s" % (idx, ext)
|
||||
elif board in ('sky9x', 'taranis'):
|
||||
result = idx + ext
|
||||
return result
|
||||
Reference in New Issue
Block a user