Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Speech-to-Speech pipeline by better support for macOS and additional OutteTTS model #752

Merged
merged 19 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,14 @@ jobs:
mv .venv/Scripts .venv/bin # venv is placed under `Scripts` on Windows
fi
source .venv/bin/activate
pip3 install maturin black pylint pytest
pip3 install maturin ruff pytest
maturin build -m apis/python/node/Cargo.toml
pip3 install target/wheels/*
dora new test_python_project --lang python --internal-create-with-path-dependencies
cd test_python_project

# Check Compliancy
black . --check
pylint --disable=C,R **/*.py
ruff check .
pip install -e ./*/
pytest

Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/node-hub-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
matrix:
platform: [ubuntu-22.04, macos-14]
folder: ${{ fromJson(needs.find-jobs.outputs.folders )}}
fail-fast: false
steps:
- name: Checkout repository
if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
Expand All @@ -49,6 +48,16 @@ jobs:
git submodule update --init --recursive
git submodule update --remote --recursive

- name: Install system-level dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get install portaudio19-dev

- name: Install system-level dependencies for MacOS
if: runner.os == 'Mac' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
run: |
brew install portaudio

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
if: runner.os == 'Linux'
Expand Down Expand Up @@ -77,7 +86,7 @@ jobs:
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
pip install black pylint pytest
pip install ruff pytest

- name: Set up Rust
if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/node_hub_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ else
if [ -f "$dir/pyproject.toml" ]; then
echo "Running linting and tests for Python project in $dir..."
pip install .
poetry run black --check .
poetry run pylint --disable=C,R --ignored-modules=cv2,pyrealsense2 **/*.py
ruff check .
poetry run pytest
fi
fi
Expand Down
8 changes: 4 additions & 4 deletions binaries/cli/src/template/python/__node-name__/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ pip install -e .

## Contribution Guide

- Format with [black](https://github.com/psf/black):
- Format with [ruff](https://docs.astral.sh/ruff/):

```bash
black . # Format
ruff check . --fix
```

- Lint with [pylint](https://github.com/pylint-dev/pylint):
- Lint with ruff:

```bash
pylint --disable=C,R --ignored-modules=cv2 . # Lint
ruff check .
```

- Test with [pytest](https://github.com/pytest-dev/pytest)
Expand Down
7 changes: 3 additions & 4 deletions binaries/cli/src/template/python/__node-name__/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ packages = [{ include = "__node_name__" }]
[tool.poetry.dependencies]
dora-rs = "^0.3.6"
numpy = "< 2.0.0"
pyarrow = ">= 5.0.0"
pyarrow = ">= 15.0.0"
python = "^3.7"

[tool.poetry.dev-dependencies]
pytest = ">= 8.3.4"
pylint = ">= 3.3.2"
black = ">= 24.10"
pytest = ">= 6.3.4"
ruff = ">= 0.9.1"

[tool.poetry.scripts]
__node-name__ = "__node_name__.main:main"
Expand Down
11 changes: 6 additions & 5 deletions binaries/cli/src/template/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ fn create_custom_node(
.with_context(|| format!("failed to write `{}`", node_path.display()))?;

// tests/tests___node_name__.py
let node_path = root
.join("tests")
.join(format!("test_{}.py", name.replace(" ", "_")));
let node_path = root.join("tests").join(format!(
"test_{}.py",
name.replace(" ", "_").replace("-", "_")
));
let file = replace_space(_TEST_PY, &name);
fs::write(&node_path, file)
.with_context(|| format!("failed to write `{}`", node_path.display()))?;
Expand All @@ -90,8 +91,8 @@ fn create_custom_node(
);
println!(" cd {}", Path::new(".").join(&root).display());
println!(" pip install -e . # Install",);
println!(" black . # Format");
println!(" pylint --disable=C,R . # Lint",);
println!(" ruff check . --fix # Format");
println!(" ruff check . # Lint",);
println!(" pytest . # Test");

Ok(())
Expand Down
1 change: 0 additions & 1 deletion examples/piper/dummy_inference_2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dora import Node


import numpy as np
import h5py

f = h5py.File("data/episode_0.hdf5", "r")
Expand Down
1 change: 0 additions & 1 deletion examples/piper/replay.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dora import Node


import numpy as np
import h5py
import os

Expand Down
1 change: 0 additions & 1 deletion examples/python-operator-dataflow/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import cv2
import time

from dora import DoraStatus
from utils import LABELS
Expand Down
3 changes: 3 additions & 0 deletions examples/speech-to-speech/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pt
*.json
*.npz
10 changes: 10 additions & 0 deletions examples/speech-to-speech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dora Speech to Text example

Make sure to have, dora, pip and cargo installed.

```bash
dora build https://raw.githubusercontent.com/dora-rs/dora/main/examples/speech-to-speech/outtetts.yml
dora run https://raw.githubusercontent.com/dora-rs/dora/main/examples/speech-to-speech/outtetts.yml

# Wait for models to download which can takes a bit of time.
```
40 changes: 40 additions & 0 deletions examples/speech-to-speech/outtetts-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
inputs:
tick: dora/timer/millis/2000
outputs:
- audio

- id: dora-vad
build: pip install -e ../../node-hub/dora-vad
path: dora-vad
inputs:
audio: dora-microphone/audio
outputs:
- audio

- id: dora-distil-whisper
build: pip install -e ../../node-hub/dora-distil-whisper
path: dora-distil-whisper
inputs:
input: dora-vad/audio
outputs:
- text
env:
TARGET_LANGUAGE: english
# For China
# USE_MODELSCOPE_HUB: true

- id: dora-outtetts
build: pip install -e ../../node-hub/dora-outtetts
path: dora-outtetts
inputs:
text: dora-whisper/text

- id: dora-rerun
build: cargo build -p dora-rerun --release
path: dora-rerun
inputs:
original_text: dora-distil-whisper/text
47 changes: 47 additions & 0 deletions examples/speech-to-speech/outtetts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
nodes:
- id: dora-microphone
description: Microphone
build: pip install dora-microphone
path: dora-microphone
inputs:
tick: dora/timer/millis/2000
outputs:
- audio

- id: dora-vad
build: pip install dora-vad
path: dora-vad
inputs:
audio: dora-microphone/audio
outputs:
- audio

- id: dora-whisper
build: pip install dora-distil-whisper
path: dora-distil-whisper
inputs:
input: dora-vad/audio
outputs:
- text
env:
TARGET_LANGUAGE: english

- id: dora-outtetts
build: pip install dora-outtetts
path: dora-outtetts
inputs:
text: dora-whisper/text
outputs:
- audio

- id: dora-pyaudio
build: pip install dora-pyaudio
path: dora-pyaudio
inputs:
audio: dora-outtetts/audio

- id: dora-rerun
build: pip install dora-rerun
path: dora-rerun
inputs:
original_text: dora-whisper/text
2 changes: 1 addition & 1 deletion node-hub/dora-argotranslate/dora_argotranslate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Read the content of the README file
try:
with open(readme_path, "r", encoding="utf-8") as f:
with open(readme_path, encoding="utf-8") as f:
__doc__ = f.read()
except FileNotFoundError:
__doc__ = "README file not found."
8 changes: 4 additions & 4 deletions node-hub/dora-argotranslate/dora_argotranslate/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

os.environ["ARGOS_DEVICE_TYPE"] = "auto"

from dora import Node
import pyarrow as pa
import argostranslate.package
import argostranslate.translate
import pyarrow as pa
from dora import Node

from_code = os.getenv("SOURCE_LANGUAGE", "fr")
to_code = os.getenv("TARGET_LANGUAGE", "en")
Expand All @@ -15,8 +15,8 @@
available_packages = argostranslate.package.get_available_packages()
package_to_install = next(
filter(
lambda x: x.from_code == from_code and x.to_code == to_code, available_packages
)
lambda x: x.from_code == from_code and x.to_code == to_code, available_packages,
),
)
argostranslate.package.install_from_path(package_to_install.download())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Read the content of the README file
try:
with open(readme_path, "r", encoding="utf-8") as f:
with open(readme_path, encoding="utf-8") as f:
__doc__ = f.read()
except FileNotFoundError:
__doc__ = "README file not found."
Loading
Loading