diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..1de7489 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,47 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker image + +on: + push: + branches: + - master + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3.0.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5.4.0 + with: + images: karlosarr/asistente-local + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + env: + DOCKER_BUILDKIT: 1 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/arm64 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..5f896a6 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,20 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..80748db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3 +LABEL maintainer="Carlos Ruiz " +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get install qemu-arm-static +RUN apt-get update && \ + apt-get --no-install-recommends install -y ffmpeg \ + libgtk2.0-0 libgtk2.0-common libportaudio2 \ + libportaudiocpp0 portaudio19-dev python3-pyaudio && \ + apt-get clean +RUN pip3 install git+https://github.com/openai/whisper.git +RUN pip3 install sounddevice +RUN pip3 install scipy +RUN pip3 install typing-extensions --upgrade +RUN mkdir -p /VA +WORKDIR /VA +COPY ./utils /VA/utils +COPY ./asistente.py /VA/asistente.py +COPY ./config.yaml /VA/config.yaml +COPY ./main.py /VA/main.py +COPY ./requirements.txt /VA/requirements.txt +RUN pip3 install -r ./requirements.txt +CMD python3 ./main.py diff --git a/README.md b/README.md index 3d4e650..415dd7a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=karlosarr_asistente_local&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=karlosarr_asistente_local) + # Asistente Virtual Local Proyecto educativo ([Lista de reprodicción en Youtube](https://www.youtube.com/watch?v=SaoDps2QBsI&list=PLA050nq-BHwN5CJuPAsFkBTrW_4Xxso_4)) para poder correr un asistente virtual de manera local. Integra distintos modelos de machine learning para poder brindar distintas funcionalidades. @@ -42,6 +44,19 @@ python main.py ``` +``` +# Ejecutar con docker compose desde la carpeta donde se clono este repositorio en la maquina huesped. +docker compose run --build --rm asistente bash + +# Ejecutar aplicación manualmente +python3 ./main.py +``` + +Ejecutar aplicación sin interación con la línea de comandos +``` +docker compose run --build --rm asistente +``` + ### x86 Ya instalado docker con NVIDIA container toolkit. @@ -57,14 +72,24 @@ cd /va python main.py ``` +# Consola interactiva con el contanedor +docker compose run --build --rm asistente bash + +ejecutar aplicación manualmente +python3 ./main.py +``` +Ejecutar aplicación sin interación con la línea de comandos +``` +docker compose run --build --rm asistente +``` ## Aportaciones Este proyecto esta abierto a aportaciones asi que si quieres mejorar o agregar funcionalidades haz un pull request. # To Do: - [X] Transcipción en tiempo real - [X] Detectar palabra clave para que el asistente sepa que se le esta hablando -- [ ] Crear Dockerfile para no requerir pull +- [X] Crear Dockerfile para no requerir pull - [ ] Modularizar el __init__ de la clase Asistente en distintas funciones - [ ] API OpenAI GPT-3 (No es local, pero su uso sera limitado) - [ ] Probar en Jetson Nano diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..25fe1af --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' + +services: + + asistente: + build: + context: . + container_name: asistente + restart: always + runtime: nvidia + network_mode: "host" + stdin_open: true + tty: true + devices: + - /dev/snd:/dev/snd + ports: + - 8080:8080 + environment: + - NVIDIA_VISIBLE_DEVICES=all + volumes: + - ./:/VA diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1f65200 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +pyyaml~=6.0 +SpeechRecognition~=3.10 +openai~=1.6.0 +gtts~=2.5.0 +pygame~=2.5.2 +#python3-pyaudio~=0.2.14 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..cf2bca4 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.projectKey=karlosarr_asistente_local +sonar.organization=karlosarr + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=asistente_local +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=. + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 +sonar.python.version=3.8