Skip to content

Commit 8343be9

Browse files
authored
Merge pull request #14 from TaskBeacon/codex/extend-build_stimulus.md-tutorial-with-voice-methods
Extend build stimulus docs
2 parents eb88090 + 24f18cb commit 8343be9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/tutorials/build_stimulus.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,30 @@ feedback:
195195
pos: [0, -2]
196196
```
197197
198+
### Converting Text Stimuli to Voice
199+
200+
`StimBank` can transform text-based stimuli into spoken audio using the
201+
`edge-tts` package. Two helper methods handle the heavy lifting for you:
202+
203+
- **`convert_to_voice()`** – Take one or more already registered text stimuli and
204+
generate an MP3 file for each. The sounds are stored in an `assets/` folder and
205+
new `Sound` stimuli with the suffix `_voice` are automatically registered.
206+
- **`add_voice()`** – Synthesize arbitrary text and register it immediately as a
207+
new voice stimulus.
208+
209+
```python
210+
# Convert existing text stimuli to speech
211+
stim_bank.convert_to_voice(["instructions", "feedback"], voice="en-US-AriaNeural")
212+
213+
# Create a brand new voice stimulus
214+
stim_bank.add_voice(
215+
"welcome_voice",
216+
"Welcome to the experiment. Press space to start.",
217+
voice="en-US-AriaNeural",
218+
)
219+
```
220+
221+
198222
### 3. Retrieving Stimuli
199223

200224
#### Getting Individual Stimuli

0 commit comments

Comments
 (0)