File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change
1
+ # WhisperTRT - ROS2 Node
2
+
3
+ This example includes a ROS2 node for interfacing with WhisperTRT.
4
+
5
+ It includes the full pipeline, including connecting to a microphone, and outputs recognized speech
6
+ segments on the `` /speech `` topic.
7
+
8
+ | Name | Description | Default |
9
+ | ------| -------------| ---------|
10
+ | model | The Whisper model to use. | "small.en" |
11
+ | backend | The Whisper backend to use. | "whisper_trt" |
12
+ | cache_dir | Directory to cache the built models. | None |
13
+ | vad_window | Number of audio chunks to use in max-filter window for voice activity detection. | 5 |
14
+ | mic_device_index | The microphone device index. | None |
15
+ | mic_sample_rate | The microphone sample rate. | 16000 |
16
+ | mic_channels | The microphone number of channels. | 6 |
17
+ | mic_bitwidth | The microphone bitwidth. | 2 |
18
+ | speech_topic | The topic to publish speech segments to. | "/speech" |
Original file line number Diff line number Diff line change 24
24
from rclpy .node import Node
25
25
from std_msgs .msg import String
26
26
from rcl_interfaces .msg import ParameterDescriptor
27
- from asr_pipeline import ASRPipeline
27
+ from whisper_trt_pipeline import WhisperTRTPipeline
28
28
29
29
30
- class AsrNode (Node ):
30
+ class WhisperTRTNode (Node ):
31
31
def __init__ (self ):
32
- super ().__init__ ('AsrNode ' )
32
+ super ().__init__ ('WhisperTRTNode ' )
33
33
34
34
self .declare_parameter ("model" , "small.en" )
35
35
self .declare_parameter ("backend" , "whisper_trt" )
@@ -66,7 +66,7 @@ def handle_asr(text):
66
66
self .speech_publisher .publish (msg )
67
67
logger .info ("published " + text )
68
68
69
- self .pipeline = ASRPipeline (
69
+ self .pipeline = WhisperTRTPipeline (
70
70
model = self .get_parameter ("model" ).value ,
71
71
vad_window = self .get_parameter ("vad_window" ).value ,
72
72
backend = self .get_parameter ("backend" ).value ,
@@ -87,7 +87,7 @@ def start_asr_pipeline(self):
87
87
88
88
def main (args = None ):
89
89
rclpy .init (args = args )
90
- node = AsrNode ()
90
+ node = WhisperTRTNode ()
91
91
92
92
node .start_asr_pipeline ()
93
93
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ def transcribe(self, audio):
301
301
self .asr_callback (text )
302
302
303
303
304
- class ASRPipeline :
304
+ class WhisperTRTPipeline :
305
305
306
306
def __init__ (self ,
307
307
model : str = "small.en" ,
@@ -389,7 +389,7 @@ def handle_vad_end():
389
389
def handle_asr (text ):
390
390
print ("asr done: " + text )
391
391
392
- pipeline = ASRPipeline (
392
+ pipeline = WhisperTRTPipeline (
393
393
model = args .model ,
394
394
backend = args .backend ,
395
395
cache_dir = args .cache_dir ,
You can’t perform that action at this time.
0 commit comments