Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added method for a save wavform as wav format #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m15kh
Copy link

@m15kh m15kh commented Nov 8, 2024

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()

@juanmc2005
Copy link
Owner

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.

@juanmc2005 juanmc2005 self-requested a review December 13, 2024 09:43
@juanmc2005 juanmc2005 added the feature New feature or request label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants