Advertisement
mightyroot

voice chess

Sep 23rd, 2011
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 3.52 KB | None | 0 0
  1. # start gnuchess in backpipe
  2. while [ 42 ] ; do nc -l -p 7777 0<backpipe | gnuchess 1>backpipe; done
  3.  
  4. # start julius stt-daemon
  5. ./julius -quiet -input mic -C julian.jconf
  6.  
  7. #start festival tts-daemon
  8. festival  -b '(voice_msu_ru_nsh_clunits)' --server &>/dev/null
  9.  
  10. echo "Вам мат" | festival --language russian --tts
  11.  
  12. #------------voice_in_gnuchess.pl------------------
  13.  
  14. #!/usr/bin/perl
  15.  
  16. while (<ARGV>)
  17. {
  18.     $linr = $_ if /sentence1/;
  19.     @string = split(/<s>/,$linr);
  20.     $string[1]=~s/<\/s>//g;
  21.     $fraza = $string[1];
  22.     print $fraza;
  23.     #system("echo '$fraza' | festival --tts");
  24.     $linr="";
  25. #---------------------------------------------------
  26.  
  27. #------------_# wave2flac.sh #_-----------------
  28. #!/bin/sh
  29. rm -r $1.flac
  30. arecord -d1 -r 8000 -t wav $1.wav
  31. ffmpeg -i $1.wav -ab 96 -ar 8000 $1.flac
  32. -------------EOF----------------------------
  33.  
  34.  
  35. --------------------# out_gnuchess.pl #---------
  36. #!/usr/bin/perl
  37. use Socket;
  38. use IO::Handle;
  39. use IO::Socket;
  40. use Text::Iconv;
  41. use locale;
  42.  
  43. $srv_ip="127.0.0.1";
  44. $srv_port="7777";
  45. $EOL = "\015\012";
  46.  
  47. #$conv = Text::Iconv->new('windows-1251','utf-8');
  48. #$conv = Text::Iconv->new('windows-1251', 'koi8-r');
  49. #$conv = Text::Iconv->new('koi8-r','utf-8');
  50. #$conv = Text::Iconv->new('utf-8','koi8-r');
  51.  
  52. socket(SERVER,PF_INET,SOCK_STREAM,getprotobyname('tcp'));
  53. $server_addr=inet_aton("$srv_ip");
  54. $paddr=sockaddr_in($srv_port,$server_addr);
  55.  
  56. connect(SERVER,$paddr);
  57. SERVER->autoflush(1);
  58. print "Connected successfully\n";
  59.  
  60. while (){
  61.     $lin = <STDIN>;
  62.     print SERVER $lin;
  63.     $l=0;
  64.  
  65.  while ($l eq 0){
  66.     $lout=<SERVER>;
  67.     $l = grep(/^My/, $lout);
  68.  
  69.      if ($lout=~/^My/){
  70.         @str=split(/:/,$lout);
  71.         print $lout;
  72.  
  73.         $lout_ru=&translit($str[1]);
  74.  
  75. #       $lout_ru=&tr2k8($str[1]);
  76.         print "ru = $lout_ru\n";
  77. #        $lout_iconv= $conv->convert($lout_ru);
  78. #        print "iconv = $lout_iconv";
  79.  
  80.         &speak($lout_ru);
  81.  
  82.      }
  83.      if ($lout=~/^Ill/){
  84.         print $lout;
  85.         $l=1;
  86.      }
  87.  
  88.  }
  89. }
  90.  
  91. close(SERVER);
  92.  
  93. exit;
  94.  
  95. sub translit
  96. {
  97.  ($_)=@_;
  98.  
  99. s/A/А/g; s/a/а/g;
  100. s/B/БЭ/g; s/b/бэ/g;
  101. s/C/ЦЭ/g; s/c/цэ/g;
  102. s/D/ДЭ/g; s/d/дэ/g;
  103. s/E/Е/g; s/e/е/g;
  104. s/F/ЭФФ/g; s/f/эфф/g;
  105. s/G/ДЖЭ/g; s/g/джэ/g;
  106. s/H/АШ/g; s/h/аш/g;
  107.  
  108. #my $text = shift;
  109. #$text=~ y/\x00-\x7F/\x80-\xFF/;
  110. #$text =~ y/abvgdeezijklmnoprstufh/'абвгдеёзийклмнопрстуфх'/;
  111. #$text =~ y/ABVGDEEZIJKLMNOPRSTUFH/'АБВГДЕЁЗИЙКЛМНОПРСТУФХ'/;
  112. return $_;
  113. }
  114.  
  115. sub tr2k8
  116.     { ($_)=@_;
  117.  
  118. s/E\'/Э/g; s/e\'/э/g;
  119. s/E/Е/g; s/e/е/g;
  120.  
  121. s/Jo/Ё/g; s/jo/ё/g;
  122. s/J\'o/Йо/g; s/j\'o/йо/g; s/J\'O/ЙО/g;
  123.  
  124. s/Sch/Щ/g; s/sch/щ/g;
  125. s/Sc\'h/Сцх/g; s/sc\'h/сцх/g; s/SC\'H/СЦХ/g;
  126.  
  127. s/Ch/Ч/g; s/ch/ч/g;
  128. s/C\'h/Цх/g; s/c\'h/цх/g; s/C\'H/ЦХ/g;
  129.  
  130. s/Sh/Ш/g; s/sh/ш/g;
  131. s/S\'h/Сх/g; s/s\'h/сх/g; s/S\'H/СХ/g;
  132.  
  133. s/Ja/Я/g; s/ja/я/g;
  134. s/J\'a/Йа/g; s/j\'a/йа/g; s/J\'A/ЙА/g;
  135.  
  136. s/Zh/Ж/g; s/zh/ж/g;
  137. s/Z\'h/Зх/g; s/z\'h/зх/g; s/Z\'H/ЗХ/g;
  138.  
  139. s/Ju/Ю/g; s/ju/ю/g;
  140. s/J\'u/Йу/g; s/j\'u/йу/g; s/J\'U/ЙУ/g;
  141.  
  142.  
  143. tr/
  144. abvgdzijklmnoprstufhc\"y\'ABVGDZIJKLMNOPRSTUFHC\"Y\'/
  145. абвгдзийклмнопрстуфхцъыьАБВГДЗИЙКЛМHОПРСТУФХЦЪЫЬ/;
  146.  
  147. return $_;
  148.  
  149. }
  150. sub speak($lout_ru){
  151. system("echo '$lout_ru' |iconv -f utf-8 -t windows-1251");
  152. #system("espeak '$lout'");
  153. system("echo '$lout_ru' |iconv -f windows-1251 -t utf-8 | festival --language russian --tts");
  154. }
  155. #-----------------------EOF------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement