Xeven7 commited on
Commit
c2819dd
·
verified ·
1 Parent(s): 2e659f0

docs: add cross-project usage section

Browse files
Files changed (1) hide show
  1. SETUP.md +57 -23
SETUP.md CHANGED
@@ -67,19 +67,19 @@ Model: .../onnx/tiny-swara-int8.onnx
67
 
68
  Play `hello.wav`. Use `--voice BM` for the male voice.
69
 
70
- | Voice | Who |
71
- |---|---|
72
- | `BF` | female (default) |
73
- | `BM` | male |
74
 
75
  Other useful options:
76
 
77
- | Option | Meaning |
78
- |---|---|
79
- | `--text-file input.txt` | read UTF-8 text from a file |
80
- | `--speed 1.2` | faster speech |
81
  | `--model onnx/tiny-swara.onnx` | use the FP32 model instead of INT8 |
82
- | `--output out.wav` | where to save |
83
 
84
  ## 5. Use it from Python
85
 
@@ -90,26 +90,60 @@ tts = TinySwara(voice="BF")
90
  tts.save("আমি তোমাকে পছন্দ করি।", "hello.wav")
91
  ```
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ## Troubleshooting
94
 
95
- | Problem | Fix |
96
- |---|---|
97
- | `espeak-ng is not installed` | Install it (step 1) and make sure `espeak-ng --version` works in the same terminal |
98
- | `ModuleNotFoundError: No module named 'tiny_voca'` | Run `python inference.py` from inside the `tiny-swara` folder |
99
- | `Could not find an ONNX model` | Keep the folder layout intact; do not move `inference.py` away from `onnx/`, `config.json`, `inventory.json`, `lexicon.json` and `tiny_voca/` |
100
- | Bengali text is garbled in the terminal | Save the sentence to a UTF-8 file and use `--text-file input.txt` |
101
- | `python3 -m venv` fails | `sudo apt install python3-venv` |
102
 
103
  `inference.py` loads `inventory.json`, `lexicon.json` and `tiny_voca/text.py`
104
  relative to itself, so always run it from the repository folder.
105
 
106
  ## What's in the folder
107
 
108
- | Path | Purpose |
109
- |---|---|
110
- | `onnx/tiny-swara-int8.onnx` | recommended model, 8.24 MiB |
111
- | `onnx/tiny-swara.onnx` | FP32 reference, 20.4 MiB |
112
- | `inference.py` | CLI and Python API |
113
- | `tiny_voca/text.py` | Bengali text-to-phoneme front end |
114
  | `config.json`, `inventory.json`, `lexicon.json` | vocabulary and pronunciation data |
115
- | `samples/` | example audio from the model card |
 
67
 
68
  Play `hello.wav`. Use `--voice BM` for the male voice.
69
 
70
+ | Voice | Who |
71
+ | ----- | ---------------- |
72
+ | `BF` | female (default) |
73
+ | `BM` | male |
74
 
75
  Other useful options:
76
 
77
+ | Option | Meaning |
78
+ | ------------------------------ | ---------------------------------- |
79
+ | `--text-file input.txt` | read UTF-8 text from a file |
80
+ | `--speed 1.2` | faster speech |
81
  | `--model onnx/tiny-swara.onnx` | use the FP32 model instead of INT8 |
82
+ | `--output out.wav` | where to save |
83
 
84
  ## 5. Use it from Python
85
 
 
90
  tts.save("আমি তোমাকে পছন্দ করি।", "hello.wav")
91
  ```
92
 
93
+ ## 6. Use it in another project
94
+
95
+ You do not have to `cd` into this folder to use the Python API. `inference.py`
96
+ finds `config.json`, `inventory.json`, `lexicon.json`, `tiny_voca/` and `onnx/`
97
+ relative to itself (not your current directory), so the folder can live
98
+ anywhere as long as you keep that layout intact.
99
+
100
+ Three things must exist in the other project's environment:
101
+
102
+ 1. **espeak-ng** — the same system package from step 1, installed once per machine.
103
+ 2. **Python dependencies** — in that project's virtual environment:
104
+ `pip install numpy onnxruntime`
105
+ 3. **This folder** — copy or clone it somewhere stable. You can drop `samples/`
106
+ and the `LICENSE`/`.md` files; keep `inference.py`, `tiny_voca/`,
107
+ `config.json`, `inventory.json`, `lexicon.json` and `onnx/`.
108
+
109
+ Then add the folder (the one containing `inference.py`) to `sys.path` and import:
110
+
111
+ ```python
112
+ import sys
113
+ sys.path.insert(0, "/path/to/tiny-swara-hf")
114
+ from inference import TinySwara
115
+
116
+ tts = TinySwara(voice="BF") # loads the INT8 model by default
117
+ tts.save("আমি তোমাকে পছন্দ করি।", "out/hello.wav")
118
+ ```
119
+
120
+ Relative output paths resolve against your current working directory, so the
121
+ WAV lands wherever your project expects it.
122
+
123
+ > If you vendor the folder _inside_ your project as a subpackage, keep it on
124
+ > `sys.path` as above. `inference.py` imports `tiny_voca` as a top-level module,
125
+ > so nesting it under a package name breaks that import.
126
+
127
  ## Troubleshooting
128
 
129
+ | Problem | Fix |
130
+ | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
131
+ | `espeak-ng is not installed` | Install it (step 1) and make sure `espeak-ng --version` works in the same terminal |
132
+ | `ModuleNotFoundError: No module named 'tiny_voca'` | Run `python inference.py` from inside the `tiny-swara` folder |
133
+ | `Could not find an ONNX model` | Keep the folder layout intact; do not move `inference.py` away from `onnx/`, `config.json`, `inventory.json`, `lexicon.json` and `tiny_voca/` |
134
+ | Bengali text is garbled in the terminal | Save the sentence to a UTF-8 file and use `--text-file input.txt` |
135
+ | `python3 -m venv` fails | `sudo apt install python3-venv` |
136
 
137
  `inference.py` loads `inventory.json`, `lexicon.json` and `tiny_voca/text.py`
138
  relative to itself, so always run it from the repository folder.
139
 
140
  ## What's in the folder
141
 
142
+ | Path | Purpose |
143
+ | ----------------------------------------------- | --------------------------------- |
144
+ | `onnx/tiny-swara-int8.onnx` | recommended model, 8.24 MiB |
145
+ | `onnx/tiny-swara.onnx` | FP32 reference, 20.4 MiB |
146
+ | `inference.py` | CLI and Python API |
147
+ | `tiny_voca/text.py` | Bengali text-to-phoneme front end |
148
  | `config.json`, `inventory.json`, `lexicon.json` | vocabulary and pronunciation data |
149
+ | `samples/` | example audio from the model card |