Verticaldev

Quando termina un viaggio sei pronto per un nuovo cammino

  blog  guide  progetti     about me

sgl.js

sdlbasic

compvter

coderdojoPV

github

threejs editor

 vrobyPages

scratch

 

TANIA

EDIT: purtroppo google ha aggiornato il browser e disattivato il voice attraverso l'interfaccia web. Ora bisogna usare il codice javascript. Nulla di realmente difficile ma in questo momento non ho tempo per modiificarlo

Avete presente Siri? Ecco la versione scritta in sdlBasic che usa google per la voce e che è in grado di eseguire i comandi sul pc. E' in pratica un esperimento che pero fatico a portare avanti 

pubblico il sorgente:

' Tania assistente vocale scritto in sdlBasic!!!
'
'
sub main
    numhost=10
    port=1234
     shell("/opt/google/chrome/chrome --app=http://localhost:1234 &")
    dim client[numhost]
    dim ret$[numhost]
    dim fname$[numhost]
    dim fparam$[numhost]
    numclient=numhost
    server=opensock(port)
    if server=0 then:print("not connetted host "):waitkey:end:end if
    if server=-1 then:print("host not exist"):waitkey:end:end if
    print("localip is :"+getlocalip()) 'not implemented in windows
    while key(27)=0
    for i= 1 to numclient
        if client[i] =0 then
        client[i]=acceptsock(server)
        if client[i] <>0 then
            'numclient+=1
            print("remote host ip is :"+getremoteip(client[i]))
            print("remote host port is :"+str$(getremoteport(client[i])))
        end if
        else
        if isclientready(client[i])=1 then
            ret$[i]=readlinesock(client[i])
            print(ret$[i])
            if left$(ret$[i],3)="GET" then
                fname$[i]="":fparam$[i]=""
                fname$[i] =mid$(ret$[i],6,instr(6,ret$[i]," ")-6)
                if instr(fname$[i],"?")<>0 then
                fparam$[i]=mid$(fname$[i],instr(fname$[i],"?")+1)
                fname$[i]=left$(fname$[i],instr(fname$[i],"?")-1)
                end if
                print(ret$[i])
            end if
            if ret$[i]=chr$(10) then
                if fparam$[i]<>"" then
                    fcmd$=lcase$(mid$(fparam$[i],instr(fparam$[i],"=")+1))
                    if left$(fcmd$,5)="cerca" then
                        'e$="espeak cerco "+mid$(fcmd$,7)
                        'shell (e$)
                        prints(fcmd$)
                        shell("killall chrome ")
                        shell("google-chrome https://www.google.it/search?q="+mid$(fcmd$,7)+" &")
                        end
                    end if
                    shell ("espeak eseguo "+fcmd$)
                    prints(fcmd$)
                    shell("killall chrome ")
                    shell(fcmd$+" &")
                    end
                end if
                    welcome$="

"
                    welcome$+="tania commander

"
                    welcome$+="

"
                    welcome$+=""
                    writelinesock(client[i],welcome$)
                    goodbie$=""
                    goodbie$+="

"
                    goodbie$+=""
                    writelinesock(client[i],goodbie$)

                while isclientready(client[i])<>0
                t$=readlinesock(client[i])
                end while
                print(str$(time)+":close socket "+str$(client[i]))
                print("---------------------------")
                closesock(client[i])
                wait(50)
                client[i]=0
            end if
        end if
        end if
    next
    end while
    for i= 1 to numclient
    if client[i]<>0 then
        writelinesock(client[i],"good bye ")
        print("close socket "+str$(client[i]))
        print("---------------------------")
        closesock(client[i])
        wait(50)
    end if
    next
    wait(500)
    closesock(server)
end sub
setdisplay(1,1,0,1)
main