Christophe CasalegnoAutoimmune warrior, Entrepreneur & Bio/Hacker

brain@127.0.0.1:~$ cat post.html

Joshua: the power of GPT-3, in bash, in your console

By Christophe Casalegno on in Linux

Well, I had planned to publish a completely different version from the one I made in the video of the same name. For those who have not watched it: it is over here!

Joshua can talk, but you can replace espeak with something sexier. However, I deliberately wanted to keep it very robotic, like Joshua in the film Wargames.

But after receiving more than 150 messages (sic!) across different platforms, I have published the first version from the video. I will publish the second one later ;)

You can download it here: joshua.sh or from the contributions page.

Remember to enter your API key in secret.cfg, as indicated at the start of joshua.sh. You can adjust many settings affecting the relevance of the response. There is no code to quit joshua (yet). Watch out: with the default settings, it can talk for pages, so be careful ;)

—
Christophe Casalegno
You can follow me on: Twitter | Facebook | LinkedIn | Telegram | YouTube | Twitch

6 comments

  1. alansan2019 · · Reply

    « Pensez à renseigner votre clef API dans le fichier secret.cfg »
    ATTENTION, pour que ça fonctionne, le fichier secret.cfg DOIT être de type exécutable de type:

    #!/bin/bash

    api_key= »sk-xxxxxxxxxxxxxxxxxxxxxxxx »

    ************************

    pour avoir une voix de qualité, j’utilise ce code:

    function text_to_speech() {
    gtts-cli -l fr -o /tmp/audio.mp3 « $1 »
    sox /tmp/audio.mp3 -p pitch 90 tempo 1.25 | sox – /tmp/isaaudio.mp3
    play -q /tmp/isaaudio.mp3
    }

    ******************

    code pour quitter joshua :

    while true; do
    read -p « >  » prompt
    response_text=$(get_response « $prompt »)
    if [[ -n « $response_text » ]]; then
    text_to_speech « $response_text » &
    display_text « $response_text »
    if [[ « $prompt » == « au revoir » ]] || [[ « $prompt » == « bye » ]]; then
    sleep 2
    exit 0
    fi
    fi
    done

    ***************
    il suffit de taper au prompt : « au revoir » ou « bye » et le script joshua se fermera après la réponse reçue !!

    perso, j’ai ajouté dans ma barre de lancement le script en tant qu’application dans un terminal, avec le lien vers le script, comme ça, je lance le script depuis une icone !!

    1. alansan2019 · · Reply

      #correction du code de sortie pour que la réponse ait le temps d’être dite en entier

      code pour quitter joshua :

      while true; do
      read -p  » >  » prompt
      response_text=$(get_response  » $prompt « )
      if [[ -n  » $response_text  » ]]; then
      text_to_speech  » $response_text  » &
      display_text  » $response_text  »
      if [[ « $prompt » == « au revoir » ]] || [[ « $prompt » == « bye » ]]; then

      display_text « $response_text »&
      text_to_speech « $response_text »&&
      sleep 1
      exit 0
      else
      text_to_speech « $response_text »&
      display_text « $response_text »
      fi
      fi
      done

    2. Hello, Alansan2019 : pas du tout concernant secret.cfg :

      11:45:46-brain@mcp:~/Coding/WOPR$ ls -latr secret.cfg
      -rw-r–r– 1 brain brain 62 15 janv. 02:25 secret.cfg

      11:46:04-brain@mcp:~/Coding/WOPR$ grep bash secret.cfg
      11:46:39-brain@mcp:~/Coding/WOPR$ grep -i bash secret.cfg

      11:47:00-brain@mcp:~/Coding/WOPR$ cat secret.cfg |cut -d ‘ »‘ -f1
      api_key=

      Il y a seulement l’api_key de renseigné.

      amicalement

      1. alansan2019 · · Reply

        merci pour la précision ;-)

        autre chose de récent: le script, ou l’api ne se connecte plus ?!
        le modèle utilisé dans le script n’est plus valide ?

  2. Merci pour ce post. Qu’il y a t-il de plus sexy que espeak pour linux qui se rapprocherait de la voix humaine ?

    1. Hello drpteck, un autre commentaire qui vient d’être publié indique justement du code pour obtenir une meilleure voix. Une autre personne avait aussi utilisé quelque chose d’autre qu’espeak, mais je dois retrouver l’email qu’il m’avait envoyé. Grosse étape dans ma vie en cours de finalisation, je reviens bientôt ;)

Leave a comment

Add a comment
Christophe Casalegno Brain 0verride

Keep it simple
and direct!