diart
diart copied to clipboard
added method for a save wavform as wav format
Hi,
I noticed that your project doesn't have a way in to save waveforms as WAV format. I have written a method for this and added it to interface.py.
To use this method, simply include the following code:
inference.attach_hooks(inference.save_waveform_hook("output"))
This code allows users to easily save any desired segment as a WAV file.
full example
from diart import SpeakerDiarization, VoiceActivityDetection, VoiceActivityDetectionConfig
from diart.sources import MicrophoneAudioSource, FileAudioSource, TorchStreamAudioSource
from diart.inference import StreamingInference
from diart.sinks import RTTMWriter
import diart.models as m
from diart import PipelineConfig
config = PipelineConfig
path_model = 'epoch=99-step=2000.ckpt'
config = VoiceActivityDetectionConfig(segmentation=m.SegmentationModel.from_pyannote(path_model))
pipeline = VoiceActivityDetection(config=config)
mic = MicrophoneAudioSource()
inference = StreamingInference(pipeline, mic, do_plot=True, do_profile=True)
inference.attach_hooks(inference.save_waveform_hook("out"))
total_prediction = inference()
Hi @m15kh, thank you for opening this PR. Leaving out behavior for very specific use cases like this one was actually a planned decision for the design of the library. The hook mechanism is a way of allowing users to craft and inject custom code into a streaming pipeline exactly in the way that you did. However, unless the feature is heavily requested and there's a very good reason to include it in the library, I would prefer to leave specific hooks out.