Почетак › Форуми › Линукс дистрибуције › Arch,Manjaro,… › Veoma zanimljiv nacin obavestavanja
- This topic has 17 одговора, 6 гласова, and was last updated 15 years, 8 months раније by wujaklija.
-
АуторЧланци
-
1. март 2009. у 8:22 pm #10816na12Учесник
Skoro sam otkrio jedan veoma zanimljiv program za konverziju teksta u govor.Program se zove espeak.Mogucnosti ima mnogo,izgovor tekstualnih fajlova,konverzija tekstualnih fajlova u wav fajlove itd.,cak postoji i podrska za srpski jezik.Ono sto zelim ovde da podelim sa vama je veoma zanimljiv nacin obavestavanja o pristigloj posti i apdejtovanju.Za to nam treba 5 skripti,dve cemo staviti u /home/user folder a tri u /etc/cron.hourly.
Prva dve koje idu u user folder su:up.sh
[code]#!/bin/sh
# Version 1.1.b2
#########################################################################################################################
### configuration setting# # of packages in output list
list_len=0# Conky parse code for “system is up to date” line
conky_parse_siutd=# Conky parse code inserted before every package name
conky_parse_pkg=# Conky parse code inserted before every package size
conky_parse_size=’${goto 160}’# Show a summary line at the end ‘true’ or anything
show_summary=’true’# Show remove package summary line at end. Set to ‘true’ or anything
show_remove_summary=’true’# # of packages in remove list, set to 0 to disable the list
rlist_len=0
# Notice that ‘show_remove_summary’ MUST be set to ‘true’ if you want to show a list of those packages# Conky parse code inserted before summary line
conky_parse_summary=### End of configuration
#########################################################################################################################declare -a pkg size
IFS=`echo -en “\n\b”`if [ “$show_remove_summary” = ‘true’ ]; then
for i in $(pacman -Qu | sed -n ‘/Remove/,/Total Re/p’ | sed ‘s/\t/\n/; s/: /\n/; s/ /\n/g’ | sed ‘s/^ //; /^$/d’ | grep ‘]’ | sed ‘s/ /!/’ | cut -d ‘!’ -f1 );
do rpkg=( “${rpkg[@]}” “$i” )
donefor i in $(pacman -Qu | sed -n ‘/Remove/,/Total Re/p’ | sed ‘s/\t/\n/; s/: /\n/; s/ /\n/g’ | sed ‘s/^ //; /^$/d’ | grep ‘]’ | sed ‘s/ /!/’ | cut -d ‘!’ -f2 );
do rsize=( “${rsize[@]}” “$i” )
done
fifor i in $(pacman -Qu | sed ‘s/\t/\n/; s/: /\n/; s/ /\n/g’ | sed -n ‘/Targets /,$p’ | sed ‘s/^ //; /^$/d’ | grep ‘]’ | sed ‘s/ /!/’ | cut -d ‘!’ -f1 );
do pkg=( “${pkg[@]}” “$i” )
donefor i in $(pacman -Qu | sed ‘s/\t/\n/; s/: /\n/; s/ /\n/g’ | sed -n ‘/Targets /,$p’ | sed ‘s/^ //; /^$/d’ | grep ‘]’ | sed ‘s/ /!/’ | cut -d ‘!’ -f2 );
do size=( “${size[@]}” “$i” )
doneIFS=$ORIGIFS
curr=0if [ “$list_len” -gt “${#pkg[@]}” ]; then list_len=${#pkg[@]}; fi
if [ “$rlist_len” -gt “${#rpkg[@]}” ]; then rlist_len=${#rpkg[@]}; fiif [ “${#pkg[@]}” = “0” ]; then echo $conky_parse_siutd “0”; exit 0; fi
while [ $curr != $list_len ]
do
echo $conky_parse_pkg ${pkg[$curr]} $conky_parse_size ${size[$curr]}
let “curr += 1”
doneif [ “$show_summary” = “true” ]; then echo $conky_parse_summary “${#pkg[@]}”; fi
if [ $show_remove_summary = ‘true’ ]; then
echo $conky_parse_siutd “${#rpkg[@]}”;
fiif [ “$rlist_len” -gt “0” ]; then
if [ “${#rpkg[@]}” -gt “0” ]; then
curr=0
while [ $curr != $rlist_len ]
do
echo $conky_parse_pkg ${rpkg[$curr]} $conky_parse_size ${rsize[$curr]}
let “curr += 1″
done
fi
fi[/code]da bi ova skripta (up.sh) radila mora da se u /etc/pacman.conf otkomentira red ‘ShowSize’
gmail.pl
[code]#!/usr/bin/perl
use Switch;
use Text::Wrap;my $what=$ARGV[0];
$user=”username”; #username for gmail account
$pass=”pasword”; #password for gmail account
$file=”/tmp/gmail.html”; #temporary file to store gmail#wrap format for subject
$Text::Wrap::columns=75; #Number of columns to wrap subject at
$initial_tab=””; #Tab for first line of subject
$subsequent_tab=”\t”; #tab for wrapped lines
$quote=”\””; #put quotes around subject#limit the number of emails to be displayed
$emails=4; #if -1 display all emails&passwd; #give password the proper url character encoding
switch($what){ #determine what the user wants
case “n” {&gmail; print “$new\n”;} #print number of new emails
case “s” { #print $from and $subj for new email
&gmail;
if ($new>0){
my $size=@from;
if ($emails!=-1 && $size>$emails){$size=$emails;} #limit number of emails displayed
for(my $i=0; $i<$size; ++$i){ print "From: $from[$i]\n"; #print from line $text=$quote.$subj[$i].$quote."\n"; print wrap($initial_tab, $subsequent_tab, $text); #print subject with word wrap } $size=@from; if ($emails!=-1 && $size >$emails){print “$emails out of $size new emails displayed\n”;}
}
}
case “e” { #print number of new emails, $from, and $subj
&gmail;
if($new==0){print “You have no new emails.\n”;}
else{
print “You have $new new email(s).\n”;
my $size=@from;
if ($emails!=-1 && $size>$emails){$size=$emails;} #limit number of emails displayed
for(my $i=0; $i<$size; ++$i){ print "From: $from[$i]\n"; #print from line $text=$quote.$subj[$i].$quote; print wrap($initial_tab, $subsequent_tab, $text); #print subject with word wrap } $size=@from; if ($emails!=-1 && $size >$emails){print “$emails out of $size new emails displayed\n”;}
}
}
else {
print “Usage Error: gmail.plsub gmail{
if(!(-e $file)){ #create file if it does not exists
`touch $file`;
}#get new emails
`wget -O – https://$user:$pass\@mail.google.com/mail/feed/atom –no-check-certificate> $file`;open(IN, $file); #open $file
my $i=0; #initialize count
$new=0; #initialize new emails to 0my $flag=0;
while(
){ #cycle through $file
if(//){$flag=1;}
elsif(/(\d+)<\/fullcount>/){$new=$1;} #grab number of new emails
elsif($flag==1){
if(/.+<\/title>/){push(@subj, &msg);} #grab new email titles
elsif(/(.+)<\/name>/){push(@from, $1); $flag=0;} #grab new email from lines
}
}close(IN); #close $file
}sub passwd{ #change to url escape codes in password
#URL ESCAPE CODES
$_=$pass;
s/\%/\%25/g;
s/\#/\%23/g;
s/\$/\%24/g;
s/\&/\%26/g;
s/\//\%2F/g;
s/\:/\%3A/g;
s/\;/\%3B/g;
s/\\%3C/g; s/\=/\%3D/g; s/\>/\%3E/g;
s/\?/\%3F/g;
s/\@/\%40/g;
s/\[/\%5B/g;
s/\\/\%5C/g;
s/\]/\%5D/g;
s/\^/\%5E/g;
s/\`/\%60/g;
s/\{/\%7B/g;
s/\|/\%7C/g;
s/\}/\%7D/g;
s/\~/\%7E/g;
$pass=$_;
}sub msg{
#THE HTML CODED CHARACTER SET [ISO-8859-1]
chomp; s/(.+)<\/title>/$1/; #get just the subject
#now replace any special characters
s/\&\#33\;/!/g; #Exclamation mark
s/\&\#34\;/”/g; s/\"\;/”/g; #Quotation mark
s/\&\#35\;/#/g; #Number sign
s/\&\#36\;/\$/g; #Dollar sign
s/\&\#37\;/%/g; #Percent sign
s/\&\#38\;/&/g; s/\&\;/&/g; #Ampersand
s/\&\#39\;/’/g; #Apostrophe
s/\&\#40\;/(/g; #Left parenthesis
s/\&\#41\;/)/g; #Right parenthesis
s/\&\#42\;/*/g; #Asterisk
s/\&\#43\;/+/g; #Plus sign
s/\&\#44\;/,/g; #Comma
s/\&\#45\;/-/g; #Hyphen
s/\&\#46\;/./g; #Period (fullstop)
s/\&\#47\;/\//g; #Solidus (slash)
s/\&\#58\;/:/g; #Colon
s/\&\#59\;/\;/g; #Semi-colon
s/\&\#60\;//g; s/\>\;/>/g; #Greater than
s/\&\#63\;/\?/g; #Question mark
s/\&\#64\;/\@/g; #Commercial at
s/\&\#91\;/\[/g; #Left square bracket
s/\&\#92\;/\\/g; #Reverse solidus (backslash)
s/\&\#93\;/\]/g; #Right square bracket
s/\&\#94\;/\^/g; #Caret
s/\&\#95\;/_/g; #Horizontal bar (underscore)
s/\&\#96\;/\`/g; #Acute accent
s/\&\#123\;/\{/g; #Left curly brace
s/\&\#124\;/|/g; #Vertical bar
s/\&\#125\;/\}/g; #Right curly brace
s/\&\#126\;/~/g; #Tilde
s/\&\#161\;/¡/g; #Inverted exclamation
s/\&\#162\;/¢/g; #Cent sign
s/\&\#163\;/£/g; #Pound sterling
s/\&\#164\;/¤/g; #General currency sign
s/\&\#165\;/¥/g; #Yen sign
s/\&\#166\;/¦/g; #Broken vertical bar
s/\&\#167\;/§/g; #Section sign
s/\&\#168\;/¨/g; #Umlaut (dieresis)
s/\&\#169\;/©/g; s/\©\;/©/g; #Copyright
s/\&\#170\;/ª/g; #Feminine ordinal
s/\&\#171\;/«/g; #Left angle quote, guillemotleft
s/\&\#172\;/¬/g; #Not sign
s/\&\#174\;/®/g; #Registered trademark
s/\&\#175\;/¯/g; #Macron accent
s/\&\#176\;/°/g; #Degree sign
s/\&\#177\;/±/g; #Plus or minus
s/\&\#178\;/²/g; #Superscript two
s/\&\#179\;/³/g; #Superscript three
s/\&\#180\;/´/g; #Acute accent
s/\&\#181\;/µ/g; #Micro sign
s/\&\#182\;/¶/g; #Paragraph sign
s/\&\#183\;/·/g; #Middle dot
s/\&\#184\;/¸/g; #Cedilla
s/\&\#185\;/¹/g; #Superscript one
s/\&\#186\;/º/g; #Masculine ordinal
s/\&\#187\;/»/g; #Right angle quote, guillemotright
s/\&\#188\;/¼/g; s/\¼\;/¼/g; # Fraction one-fourth
s/\&\#189\;/½/g; s/\½\;/½/g; # Fraction one-half
s/\&\#190\;/¾/g; s/\¾\;/¾/g; # Fraction three-fourths
s/\&\#191\;/¿/g; #Inverted question mark
s/\&\#192\;/À/g; #Capital A, grave accent
s/\&\#193\;/Á/g; #Capital A, acute accent
s/\&\#194\;/Â/g; #Capital A, circumflex accent
s/\&\#195\;/Ã/g; #Capital A, tilde
s/\&\#196\;/Ä/g; #Capital A, dieresis or umlaut mark
s/\&\#197\;/Å/g; #Capital A, ring
s/\&\#198\;/Æ/g; #Capital AE dipthong (ligature)
s/\&\#199\;/Ç/g; #Capital C, cedilla
s/\&\#200\;/È/g; #Capital E, grave accent
s/\&\#201\;/É/g; #Capital E, acute accent
s/\&\#202\;/Ê/g; #Capital E, circumflex accent
s/\&\#203\;/Ë/g; #Capital E, dieresis or umlaut mark
s/\&\#204\;/Ì/g; #Capital I, grave accent
s/\&\#205\;/Í/g; #Capital I, acute accent
s/\&\#206\;/Î/g; #Capital I, circumflex accent
s/\&\#207\;/Ï/g; #Capital I, dieresis or umlaut mark
s/\&\#208\;/Ð/g; #Capital Eth, Icelandic
s/\&\#209\;/Ñ/g; #Capital N, tilde
s/\&\#210\;/Ò/g; #Capital O, grave accent
s/\&\#211\;/Ó/g; #Capital O, acute accent
s/\&\#212\;/Ô/g; #Capital O, circumflex accent
s/\&\#213\;/Õ/g; #Capital O, tilde
s/\&\#214\;/Ö/g; #Capital O, dieresis or umlaut mark
s/\&\#215\;/×/g; #Multiply sign
s/\&\#216\;/Ø/g; #Capital O, slash
s/\&\#217\;/Ù/g; #Capital U, grave accent
s/\&\#218\;/Ú/g; #Capital U, acute accent
s/\&\#219\;/Û/g; #Capital U, circumflex accent
s/\&\#220\;/Ü/g; #Capital U, dieresis or umlaut mark
s/\&\#221\;/Ý/g; #Capital Y, acute accent
s/\&\#222\;/Þ/g; #Capital THORN, Icelandic
s/\&\#223\;/ß/g; #Small sharp s, German (sz ligature)
s/\&\#224\;/à/g; #Small a, grave accent
s/\&\#225\;/á/g; #Small a, acute accent
s/\&\#226\;/â/g; #Small a, circumflex accent
s/\&\#227\;/ã/g; #Small a, tilde
s/\&\#228\;/ä/g; #Small a, dieresis or umlaut mark
s/\&\#229\;/å/g; #Small a, ring
s/\&\#230\;/æ/g; #Small ae dipthong (ligature)
s/\&\#231\;/ç/g; #Small c, cedilla
s/\&\#232\;/è/g; #Small e, grave accent
s/\&\#233\;/é/g; #Small e, acute accent
s/\&\#234\;/ê/g; #Small e, circumflex accent
s/\&\#235\;/ë/g; #Small e, dieresis or umlaut mark
s/\&\#236\;/ì/g; #Small i, grave accent
s/\&\#237\;/í/g; #Small i, acute accent
s/\&\#238\;/î/g; #Small i, circumflex accent
s/\&\#239\;/ï/g; #Small i, dieresis or umlaut mark
s/\&\#240\;/ð/g; #Small eth, Icelandic
s/\&\#241\;/ñ/g; #Small n, tilde
s/\&\#242\;/ò/g; #Small o, grave accent
s/\&\#243\;/ó/g; #Small o, acute accent
s/\&\#244\;/ô/g; #Small o, circumflex accent
s/\&\#245\;/õ/g; #Small o, tilde
s/\&\#246\;/ö/g; #Small o, dieresis or umlaut mark
s/\&\#247\;/÷/g; #Division sign
s/\&\#248\;/ø/g; #Small o, slash
s/\&\#249\;/ù/g; #Small u, grave accent
s/\&\#250\;/ú/g; #Small u, acute accent
s/\&\#251\;/û/g; #Small u, circumflex accent
s/\&\#252\;/ü/g; #Small u, dieresis or umlaut mark
s/\&\#253\;/ý/g; #Small y, acute accent
s/\&\#254\;/þ/g; #Small thorn, Icelandic
s/\&\#255\;/ÿ/g; #Small y, dieresis or umlaut mark
s/^\s+//;
return $_;
}[/code]ovde je potrebno ubaciti username i lozinku
druge tri koje idu u cron.hourly suposta.sh
[code]#!/bin/bash
BROJ=$(perl /home/user/gmail.pl n)
if [ “$BROJ” -gt “0” ]; then
espeak -v sr “stigla vam je nova pošta! broj nepročitanih pisama je! $BROJ”
fi [/code]updates.sh
[code]#!/bin/bash
sh /home/user/up.sh > /home/user/.pacmanupdates.txt
BROJ=$(tail -n1 /home/user/.pacmanupdates.txt)
BROJD=$(head -n1 /home/user/.pacmanupdates.txt)
if [ “$BROJD” -gt “0” ]; then
espeak -v sr “sistem arč linuks! kernel 2 6 29! broj paketa za nadogradnju! $BROJD”
fi
if [ “$BROJ” -gt “0” ]; then
espeak -v sr “broj paketa za uklanjanje sa sistema! $BROJ”
fi
[/code]ovde je potrebno umesto user staviti svog user-a
i sync.sh
[code]#!/bin/bash
pacman -Sy[/code]ne zaboraviti da se sa skriptama uradi chmod +x,i naravno instalirajte espeak,nalazi se u community repo-u. O0
2. март 2009. у 6:20 am #76267na12УчесникDa dodam jos jedu zanimljivu mogucnost espeak programa.Za to nam treba jos i xsel program koji se nalazi isto u community repo-u,i jedna skripta.Sta zapravo radi ova skripta.Pa ona cita sve u X11 sto je oznaceno(highlight) bilo da je tekst na cirilici ili latinici.
Skripta kazi.sh
[code]#!/bin/sh
espeak -v sr “`xsel -p -o`”[/code]
Ne zaboraviti da se skripti dodeli execute permission.
Da bi smo sve ovo malo automatizovali, dodelicemo precicu na tastaturi ovoj skripti,u xfce se to radi preko
settings-keyboard-aplication shortcuts-add.U gnome okruzenju se ide na applications-system tools-configuration editor-apps-metacity-keybiding_commands,tu se odabere command_1 i definise put do skripte,npr sh /home/user/kazi.sh,i na kraju se u global_keybidings upise precica u liniju run_command_1,npr F3. Sada kada oznacimo neki tekst bilo da je on u openoffice,nekom browser-u,text editor-u ili nekoj drugoj aplikaciji ili desktop-u,samo pritisnemo nasu precicu koju smo prethodno definisali i oznaceni tekst ce biti procitan.Ako zelimo da cujemo odredjeni tekst na englskom jeziku samo treba izbaciti iz skripte -v sr,ili na nemackom dodati -v de,ili mozete napraviti skriptu i precicu za svaki jezik posebno.Postoji jos preko 40 jezika pa odaberite koji zelite.2. март 2009. у 3:22 pm #76268na12УчесникEvo jos jedna skripta stize od mene.Radi se o prevodjenju pomocu govora.Prvo nam treba paket iz AUR-a pod nazivom translate-git,onda sa sledecom skriptom uraditi kao i sa prethodnom:
prevedi.sh
[code]#!/bin/sh
espeak -v sr “$(translate en hr `xsel -p -o`)”[/code]znaci dodeliti precicu itd.
Kad se oznaci neki tekst na engleskom i pritisne npr. F3 cuce se prevod na srpski odnosno ja sam ovde stavio na hrvatski zato sto jos nisam nasao nacin da resim problem sa cirilicom koju google koristi za prevod na srpski jezik.Umesto englesko-hrvatske kombinacije moze se koristiti bilo koja kombinacija koju google podrzava.
To se menja ovde(boldovano je)->espeak -v sr “$(translate en hr `xsel -p -o`)”2. март 2009. у 4:11 pm #76269DemonУчесникOpa! Super!
2. март 2009. у 9:10 pm #76270djvujkeУчесникsuper! jos kad bi espeak hteo da mi proradi 🙁
2. март 2009. у 11:35 pm #76271na12Учесникsuper! jos kad bi espeak hteo da mi proradi 🙁
Meni radi odlicno,nijedan problem sa tim programom do sada nisam imao,ne znam sta bi kod tebe moglo da bude,jos je kod mene 64bitni arch.
3. март 2009. у 6:36 pm #76272djvujkeУчесникsuse 11.0 i ….
ailed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 957
memphisto@nw8240linux:~> espeak
Expression ‘parameters->channelCount channelCount channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 764
Expression 'ValidateParameters( outputParameters, hostApi, StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 957koji mu je ne znam
3. март 2009. у 8:49 pm #76273na12УчесникOcigledno je problem u ALSA konfiguraciji,probaj festival da vidis da li je do programa ili alsa-e,mada on nema podrsku za srpski.Kod mene,a i kod drugih na 64-bitnom arch-u festival nece da radi,dok espeak super radi.
27. март 2009. у 12:26 am #76274wujaklijaУчесникevo nacina citanja poruka sa skype-a pomocu espeak programa :
– instalira se skype4py http://sourceforge.net/project/showfiles.php?group_id=202148
– skini python skriptu http://pastebin.com/f58e304b6
– preimenuj u npr. : chatespeak.py
– zatim [code]chmod +x chatespeak.py[/code]
– pokreni skype
– pokreni skriptu [code]python /putanja/do/skripte/chatespeak.py[/code]Kad stigne poruka reci ce vam ko vam je poslao i sadrzaj poruke …
28. март 2009. у 4:17 pm #76275KosavaУчесникxtra je ovaj program biobi xtra da nije ovakav robotski glas onda bi bilo prijatno slušat tekst kad bi se neka knjiga učitala hehe 😀
-
АуторЧланци
Мораш бити пријављен да би поставио коментар у овој теми.