mirror of
https://github.com/kmein/niveum
synced 2026-03-21 12:21:08 +01:00
tlg-wotd: use cltk for transcription
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
niveumPackages,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
systemd.services.telegram-bot-tlg-wotd = {
|
systemd.services.telegram-bot-tlg-wotd = {
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
path = [ pkgs.jq pkgs.curl pkgs.recode pkgs.deno pkgs.imagemagick pkgs.gawk pkgs.gnugrep pkgs.coreutils ];
|
path = [ pkgs.jq pkgs.curl pkgs.recode pkgs.deno pkgs.imagemagick pkgs.gawk pkgs.gnugrep pkgs.coreutils ];
|
||||||
environment = {
|
environment = {
|
||||||
NPM_CONFIG_CACHE = "/tmp";
|
NPM_CONFIG_CACHE = "/tmp";
|
||||||
DENO_DIR = "/tmp";
|
CLTK_DATA = "/tmp";
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
set -efux
|
set -efux
|
||||||
@@ -29,9 +30,17 @@
|
|||||||
first_occurrence=$(echo "$json_data" | jq -r '.firstOccurrence')
|
first_occurrence=$(echo "$json_data" | jq -r '.firstOccurrence')
|
||||||
total_occurrences=$(echo "$json_data" | jq -r '.totalOccurrences')
|
total_occurrences=$(echo "$json_data" | jq -r '.totalOccurrences')
|
||||||
|
|
||||||
transliteration=$(deno run ${pkgs.writeText "translit.ts" ''
|
transliteration=$(${pkgs.writers.writePython3 "translit.py" {
|
||||||
import grc from "npm:greek-transliteration";
|
libraries = [ niveumPackages.cltk ];
|
||||||
console.log(grc.transliterate(Deno.args.join(" ")));
|
} ''
|
||||||
|
import sys
|
||||||
|
from cltk.phonology.grc.transcription import Transcriber
|
||||||
|
|
||||||
|
probert = Transcriber("Attic", "Probert")
|
||||||
|
text = " ".join(sys.argv[1:])
|
||||||
|
ipa = probert.transcribe(text)
|
||||||
|
|
||||||
|
print(ipa)
|
||||||
''} "$compact_word")
|
''} "$compact_word")
|
||||||
|
|
||||||
|
|
||||||
@@ -87,9 +96,9 @@
|
|||||||
-font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Regular.ttf" \
|
-font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Regular.ttf" \
|
||||||
-fill "$color2" \
|
-fill "$color2" \
|
||||||
-pointsize 60 -gravity west \
|
-pointsize 60 -gravity west \
|
||||||
-annotate +100+00 "/$transliteration/" \
|
-annotate +100+00 "$transliteration" \
|
||||||
-fill "$color1" \
|
-fill "$color1" \
|
||||||
-annotate +100+100 "‘$definition’" \
|
-annotate +100+120 "‘$definition’" \
|
||||||
-fill "$color2" \
|
-fill "$color2" \
|
||||||
-pointsize 40 -gravity southwest \
|
-pointsize 40 -gravity southwest \
|
||||||
-annotate +100+60 "t.me/TLGWotD" \
|
-annotate +100+60 "t.me/TLGWotD" \
|
||||||
|
|||||||
Reference in New Issue
Block a user