Giter Club home page Giter Club logo

html5_ollama_speech's Introduction

HTML5_Ollama_Speech

  • This HTML5 example uses the Ollama REST API and the browser Speech API to add speech detection and speech synthesis for Ollama.

  • Web Demo - Note for the demo to work you need the Ollama chat API to add the Access-Control-Allow-Origin: * header. (See below)

Screenshots

image_1

Dependencies

Windows

docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
  • Install the llama2 model:
docker exec -it ollama ollama run llama2

Add Custom Headers to a NGINX Proxy in the Docker Container

You can create a new Ollama container to add a nginx proxy with the required header. If you don't want to use the proxy, just clone the repository and use the live-preview VS Code extension to preview the index.html and it will work without the header. In the future it would be better to modify the client Golang code to add the header so that websites can talk directly to the Ollama REST API.

  • First recreate the docker container with an additional port for the nginx proxy.
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 -p 11435:11435 --name ollama ollama/ollama
  • Install the llama2 model:
docker exec -it ollama ollama run llama2

image_2

  • Add vim to edit configs
apt-get update
apt-get install vim
  • Install nginx to run a web proxy which adds the custom header
apt-get install nginx
  • Edit the nginx configuration
vi /etc/nginx/sites-available/default
  • Add the proxy settings and custom header
server {
 listen 11435;
 location / {
   if ($request_method = 'OPTIONS') {
     add_header 'Access-Control-Allow-Origin' '*';
     add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
     add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
     add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
     return 204;
   }
   proxy_pass http://localhost:11434;
 }
 proxy_hide_header 'Access-Control-Allow-Origin';
 proxy_set_header 'Access-Control-Allow-Origin' "*";
 proxy_hide_header 'Content-Type';
 proxy_set_header 'Content-Type' "application/json";
 proxy_hide_header 'Origin';
 proxy_set_header 'Origin' "https://localhost:11434";
 add_header 'Access-Control-Allow-Origin' '*';
 proxy_hide_header 'Sec-Fetch-Mode';
 proxy_hide_header 'Sec-Fetch-Site';
 proxy_hide_header 'Sec-Fetch-Dest';
 proxy_hide_header 'Origin';
}
  • Test if the configuration changes are okay.
nginx -t
  • Reload the nginx service
service nginx reload
  • Start the nginx proxy server
nginx

html5_ollama_speech's People

Contributors

tgraupmann avatar bitdeep avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.