Skip to content

Commit

Permalink
Adding translation example using VAD, OPUS, ArgoTranslate, and a pret…
Browse files Browse the repository at this point in the history
…ty printer for better readibility
  • Loading branch information
haixuanTao committed Oct 9, 2024
1 parent d572bd6 commit 15f123a
Show file tree
Hide file tree
Showing 31 changed files with 696 additions and 145 deletions.
12 changes: 0 additions & 12 deletions examples/argostranslate/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions examples/argostranslate/argo_translate_op.py

This file was deleted.

15 changes: 0 additions & 15 deletions examples/argostranslate/dataflow.yml

This file was deleted.

20 changes: 0 additions & 20 deletions examples/argostranslate/write_op.py

This file was deleted.

File renamed without changes.
14 changes: 14 additions & 0 deletions examples/translation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dora argo example

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

```bash
# Install rerun if it's not done already
dora up

dora build dataflow_cn_terminal.yml
dora start dataflow_cn_terminal.yml

# In another terminal
python pretty_print.py
```
47 changes: 47 additions & 0 deletions examples/translation/dataflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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: chinese
TRANSLATE: false

- id: dora-argotranslate
build: pip install -e ../../node-hub/dora-argotranslate
path: dora-argotranslate
inputs:
text:
source: dora-distil-whisper/text
queue_size: 1
outputs:
- text
env:
SOURCE_LANGUAGE: zh
TARGET_LANGUAGE: en

- id: plot
build: cargo build -p dora-rerun --release
path: dora-rerun
inputs:
text: dora-argotranslate/text
env:
IMAGE_WIDTH: 640
IMAGE_HEIGHT: 480
46 changes: 46 additions & 0 deletions examples/translation/dataflow_cn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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: chinese
TRANSLATE: false

- id: dora-opus
build: pip install -e ../../node-hub/dora-opus
path: dora-opus
inputs:
text: dora-distil-whisper/text
outputs:
- text
env:
SOURCE_LANGUAGE: zh
TARGET_LANGUAGE: en

- id: plot
build: cargo build -p dora-rerun --release
path: dora-rerun
inputs:
translated_text: dora-opus/text
original_text: dora-distil-whisper/text
env:
IMAGE_WIDTH: 640
IMAGE_HEIGHT: 480
42 changes: 42 additions & 0 deletions examples/translation/dataflow_cn_terminal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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: chinese
TRANSLATE: false

- id: dora-opus
build: pip install -e ../../node-hub/dora-opus
path: dora-opus
inputs:
text: dora-distil-whisper/text
outputs:
- text
env:
SOURCE_LANGUAGE: zh
TARGET_LANGUAGE: en

- id: pretty-print
path: dynamic
inputs:
translated_text: dora-opus/text
original_text: dora-distil-whisper/text
45 changes: 45 additions & 0 deletions examples/translation/dataflow_en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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
TRANSLATE: false

- id: dora-argotranslate
build: pip install -e ../../node-hub/dora-argotranslate
path: dora-argotranslate
inputs:
text: dora-distil-whisper/text
outputs:
- text
env:
SOURCE_LANGUAGE: en
TARGET_LANGUAGE: zh

- id: dora-rerun
build: cargo build -p dora-rerun --release
path: dora-rerun
inputs:
text: dora-argotranslate/text
env:
IMAGE_WIDTH: 640
IMAGE_HEIGHT: 480
45 changes: 45 additions & 0 deletions examples/translation/dataflow_en_terminal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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
TRANSLATE: false

- id: dora-opus
build: pip install -e ../../node-hub/dora-opus
path: dora-opus
inputs:
text: dora-distil-whisper/text
outputs:
- text
env:
SOURCE_LANGUAGE: en
TARGET_LANGUAGE: zh

- id: pretty-print
path: dynamic
inputs:
translated_text: dora-opus/text
original_text: dora-distil-whisper/text
env:
IMAGE_WIDTH: 640
IMAGE_HEIGHT: 480
46 changes: 46 additions & 0 deletions examples/translation/dataflow_en_terminal_argo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
nodes:
- id: dora-microphone
build: pip install -e ../../node-hub/dora-microphone
path: dora-microphone
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
TRANSLATE: false

- id: dora-argotranslate
build: pip install -e ../../node-hub/dora-argotranslate
path: dora-argotranslate
inputs:
text: dora-distil-whisper/text
outputs:
- text
env:
SOURCE_LANGUAGE: en
TARGET_LANGUAGE: zh

- id: pretty-print
build: cargo build -p dora-rerun --release
path: dynamic
inputs:
translated_text: dora-argotranslate/text
original_text: dora-distil-whisper/text
env:
IMAGE_WIDTH: 640
IMAGE_HEIGHT: 480
Loading

0 comments on commit 15f123a

Please sign in to comment.