Merge pull request #60 from Brainik/patch-5

Czech voice navigation optimized for the SVOX TTS engine.
This commit is contained in:
pavolzibrita 2011-09-09 08:18:31 -07:00
commit 07cf3f0a9a

View file

@ -1,3 +1,9 @@
% Czech navigation commands optimized for SVOX Classic TTS engine
% TODO:
% maybe use "zahněte" instead of "odbočte"
% optimize "pak držte se vlevo" -> "pak se držte vlevo"
:- op('==', xfy, 500). :- op('==', xfy, 500).
version(101). version(101).
language(cs). language(cs).
@ -21,63 +27,103 @@ pturn('right', ['vpravo']).
pturn('right_sh', ['ostře vpravo']). pturn('right_sh', ['ostře vpravo']).
pturn('right_sl', ['mírně vpravo']). pturn('right_sl', ['mírně vpravo']).
prepare_turn(Turn, Dist) == ['o', D, 'budete odbočovat', M] :- prepare_turn(Turn, Dist) == ['po', D, 'budete odbočovat', M] :-
distance(Dist) == D, pturn(Turn, M). distance(Dist,locative) == D, pturn(Turn, M).
turn(Turn, Dist) == ['o', D, M] :- turn(Turn, Dist) == ['po', D, M] :-
distance(Dist) == D, turn(Turn, M). distance(Dist,locative) == D, turn(Turn, M).
turn(Turn) == M :- turn(Turn, M). turn(Turn) == M :- turn(Turn, M).
prepare_make_ut(Dist) == ['o', D, 'se budete otáčet zpět'] :- prepare_make_ut(Dist) == ['po', D, 'se budete otáčet zpět'] :-
distance(Dist) == D. distance(Dist,locative) == D.
prepare_roundabout(Dist) == ['o', D, 'přijedete na kruhový objezd'] :- prepare_roundabout(Dist) == ['po', D, 'přijedete na kruhový objezd'] :-
distance(Dist) == D. distance(Dist,locative) == D.
make_ut(Dist) == ['o', D, 'se otočte zpět'] :- make_ut(Dist) == ['po', D, 'se otočte zpět'] :-
distance(Dist) == D. distance(Dist,locative) == D.
make_ut == ['otočte se zpět']. make_ut == ['otočte se zpět'].
roundabout(Dist, _Angle, Exit) == ['o', D, 'vjeďte na kruhový objezd', 'a zvolte', E, 'výjezd'] :- roundabout(Dist, _Angle, Exit) == ['po', D, 'vjeďte na kruhový objezd', 'a zvolte', E, 'výjezd'] :-
distance(Dist) == D, nth(Exit, E). distance(Dist,locative) == D, nth(Exit, nominative, E).
roundabout(_Angle, Exit) == ['jděte cez', E, 'výjezd'] :- nth(Exit, E). roundabout(_Angle, Exit) == ['vyjeďte', E, 'výjezdem'] :- nth(Exit, instrumental, E).
and_arrive_destination == ['a dorazíte do cíle']. % Miss and? and_arrive_destination == ['a dorazíte do cíle']. % Miss and?
then == ['pak']. then == ['pak'].
reached_destination == ['dorazili jste do cíle']. reached_destination == ['dorazili jste do cíle'].
bear_right == ['držte se vpravo']. bear_right == ['držte se vpravo'].
bear_left == ['držte se vlevo']. bear_left == ['držte se vlevo'].
route_recalc(_Dist) == ['přepočítávám']. % nothing to said possibly beep? route_recalc(_Dist) == ['přepočítávám']. % nothing to said possibly beep?
route_new_calc(Dist) == ['cesta je dlouhá', D] :- distance(Dist) == D. % nothing to said possibly beep? route_new_calc(Dist) == ['cesta je dlouhá', D] :- distance(Dist,accusative) == D. % nothing to said possibly beep?
go_ahead(Dist) == ['pokračujte', D]:- distance(Dist) == D. % SVOX bug workaround - see below
go_ahead(Dist) == ['pokračujte', D]:- distance(Dist,workaround) == D.
go_ahead == ['pokračujte rovně']. go_ahead == ['pokračujte rovně'].
%% %%
nth(1, 'první'). nth(1, nominative, 'první').
nth(2, 'druhý'). nth(1, instrumental, 'prvním').
nth(3, 'třetí'). nth(2, nominative, 'druhý').
nth(4, 'čtvrtý'). nth(2, instrumental, 'druhým').
nth(5, 'pátý'). nth(3, nominative, 'třetí').
nth(6, 'šestý'). nth(3, instrumental, 'třetím').
nth(7, 'sedmý'). nth(4, nominative, 'čtvrtý').
nth(8, 'osmý'). nth(4, instrumental, 'čtvrtým').
nth(9, 'devátý'). nth(5, nominative, 'pátý').
nth(10, 'desátý'). nth(5, instrumental, 'pátým').
nth(11, 'jedenáctý'). nth(6, nominative, 'šestý').
nth(12, 'dvanáctý'). nth(6, instrumental, 'šestým').
nth(13, 'třináctý'). nth(7, nominative, 'sedmý').
nth(14, 'čtrnáctý'). nth(7, instrumental, 'sedmým').
nth(15, 'patnáctý'). nth(8, nominative, 'osmý').
nth(16, 'šestnáctý'). nth(8, instrumental, 'osmým').
nth(17, 'sedmnáctý'). nth(9, nominative, 'devátý').
nth(9, instrumental, 'devátým').
nth(10, nominative, 'desátý').
nth(10, instrumental, 'desátým').
nth(11, nominative, 'jedenáctý').
nth(11, instrumental, 'jedenáctým').
nth(12, nominative, 'dvanáctý').
nth(12, instrumental, 'dvanáctým').
nth(13, nominative, 'třináctý').
nth(13, instrumental, 'třináctým').
nth(14, nominative, 'čtrnáctý').
nth(14, instrumental, 'čtrnáctým').
nth(15, nominative, 'patnáctý').
nth(15, instrumental, 'patnáctým').
nth(16, nominative, 'šestnáctý').
nth(16, instrumental, 'šestnáctým').
nth(17, nominative, 'sedmnáctý').
nth(17, instrumental, 'sedmnáctým').
%%% distance measure %%% distance measure - accusative
distance(Dist) == [ X, 'metrů'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X). % workaround of wrong declination in SVOX
distance(Dist) == [ X, 'metrů'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X). % example: "pokracujte pet metru"
distance(Dist) == ['přibližně jeden kilometr'] :- Dist < 1500. % SVOX bug: without "dál" says "pokračujte osmdesáti metrů" instead of "pokračujte osmdesát metrů"
distance(Dist) == ['přibližně', X, 'kilometry'] :- Dist < 4500, D is round(Dist/1000), num_atom(D, X). % "pokračujte rovně 80 metrů" does not work either
distance(Dist) == ['přibližně', X, 'kilometrů'] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X). % SVOX bug: "pokracujte dal priblizne 3 kilometry" is pronounced as "pokracujte dal priblizne tremi kilometry"
distance(Dist) == [ X, 'kilometrů'] :- D is round(Dist/1000), num_atom(D, X). distance(Dist,workaround) == [ 'dál', X, 'metrů'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X).
distance(Dist,workaround) == [ 'dál', X, 'metrů'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X).
distance(Dist,workaround) == ['přibližně jeden kilometr'] :- Dist < 1500.
distance(Dist,workaround) == ['přibližně', X, 'kilometry'] :- Dist < 4500, D is round(Dist/1000), num_atom(D, X).
distance(Dist,workaround) == ['dál přibližně', X, 'kilometrů'] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X).
distance(Dist,workaround) == [ 'dál', X, 'kilometrů'] :- D is round(Dist/1000), num_atom(D, X).
%%% distance measure - accusative
% example: "pokracujte pet metru"
distance(Dist,accusative) == [ X, 'metrů'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X).
distance(Dist,accusative) == [ X, 'metrů'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X).
distance(Dist,accusative) == ['přibližně jeden kilometr'] :- Dist < 1500.
distance(Dist,accusative) == ['přibližně', X, 'kilometry'] :- Dist < 4500, D is round(Dist/1000), num_atom(D, X).
distance(Dist,accusative) == ['přibližně', X, 'kilometrů'] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X).
distance(Dist,accusative) == [ X, 'kilometrů'] :- D is round(Dist/1000), num_atom(D, X).
%%% distance measure - locative
% example: "po peti metrech zabocte vpravo"
distance(Dist,locative) == [ X, 'metrech'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X).
distance(Dist,locative) == [ X, 'metrech'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X).
distance(Dist,locative) == ['přibližně jednom kilometru'] :- Dist < 1500.
distance(Dist,locative) == ['přibližně', X, 'kilometrech'] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X).
distance(Dist,locative) == [ X, 'kilometrech'] :- D is round(Dist/1000), num_atom(D, X).
%% resolve command main method %% resolve command main method
%% if you are familar with Prolog you can input specific to the whole mechanism, %% if you are familar with Prolog you can input specific to the whole mechanism,
@ -85,9 +131,11 @@ distance(Dist) == [ X, 'kilometrů'] :- D is round(Dist/1000), num_atom(D, X).
flatten(X, Y) :- flatten(X, [], Y), !. flatten(X, Y) :- flatten(X, [], Y), !.
flatten([], Acc, Acc). flatten([], Acc, Acc).
flatten([X|Y], Acc, Res):- flatten([X|Y], Acc, Res):-
flatten(Y, Acc, R), flatten(X, R, Res). flatten(Y, Acc, R), flatten(X, R, Res).
flatten(X, Acc, [X|Acc]). flatten(X, Acc, [X|Acc]).
resolve(X, Y) :- resolve_impl(X,Z), flatten(Z, Y). resolve(X, Y) :- resolve_impl(X,Z), flatten(Z, Y).
resolve_impl([],[]). resolve_impl([],[]).
resolve_impl([X|Rest], List) :- resolve_impl(Rest, Tail), ((X == L) -> append(L, Tail, List); List = Tail). resolve_impl([X|Rest], List) :- resolve_impl(Rest, Tail), ((X == L) -> append(L, Tail, List); List = Tail).