Giter VIP home page Giter VIP logo

augnito-speaker-diarization's Introduction

To install the environment

conda create --prefix ./augnito python=3.9
conda activate ./augnito
./augnito/bin/python3 -m pip install -r requirements.txt

To install and prepare the dataset

git clone https://github.com/babylonhealth/primock57
cd primock57/scripts/
bash mix_audio.sh

make the following changes in textgrid_to_transcript.py (inside primock57/scripts/)

# line 15, from this
return [f"{u['speaker']}: {strip_transcript_tags(u['text'])}"
            for u in combined_utterances]
# to
return [f"{u['from']}::{u['to']}::{u['speaker']}::{strip_transcript_tags(u['text'])}"
            for u in combined_utterances]
python3 textgrid_to_transcript.py --transcript_path ../transcripts --output_path ../output/joined_transcripts
cd ../../ # go to home dir
python3 transcript_to_timestamps.py # to convert the joined_transcripts into timestamps

NOTE: Doctor is SPEAKER_00 and patient is SPEAKER_01 in the timestamps

To prepare pyannote dataset

We need to create a pyannote.dataset using the above dataset for finetuning the model.

python3 make_pyan_database.py # will create necessary files in pyan_db directory

Create a file database.yml in the home dir, and add the following

Databases:
  Primock: primock57/output/mixed_audio/{uri}.wav

Protocols:
  Primock:
    SpeakerDiarization:
      full:
        train:
            uri: pyan_db/train_list.txt
            annotation: pyan_db/rttms/train_{uri}.rttm
            annotated: pyan_db/uems/train_{uri}.uem
        development:
            uri: pyan_db/dev_list.txt
            annotation: pyan_db/rttms/dev_{uri}.rttm
            annotated: pyan_db/uems/dev_{uri}.uem
        test:
            uri: pyan_db/test_list.txt
            annotation: pyan_db/rttms/test_{uri}.rttm
            annotated: pyan_db/uems/test_{uri}.uem

To check if the pyannote.dataset was created properly

python3 check_protocol.py

How to run

pyan_finetune.ipynb has the code to finetune the SpeakerDiarization model using pyannote/speaker-diarization-3.1 and pyannote/segmentation-3.0. It uses the created database.yml pyannote.dataset to do this.

pyan_inf.ipynb will run inference on the dataset using both the pretrained and finetuned models and create the output directories timestamps_pyan_diar_pretrained and timestamps_pyan_diar_pretrained.

nemo_inf.ipynb will run inference on the dataset using pretrainedmarblenet-vad, titanet_large-speaker_embedder and creates the output directory timestamps_nemo_pretrained.

der.ipynb has the code to calculate Diarization Error Rate (DER) for all the models used.

The final report of the assignment can be found as Report.pdf.

augnito-speaker-diarization's People

Contributors

saiakarsh193 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.