Skip to main content

A diarization package

Project description

EternalBlue is a project for audio diarization and transcription. It separates speakers in a .wav audio file and returns the diarized and transcribed audio.

Description

EternalBlue is a powerful tool for audio analysis, capable of identifying and separating different speakers in a .wav audio file. Additionally, it performs complete transcription of the spoken content, facilitating the analysis and interpretation of conversations.

Installation

Requirements

  • Python 3.8 or higher

Installation Steps

You can install EternalBlue via pip:

pip install eternalblue

Usage

from eternalblue import EternalBlue
eternal_blue = EternalBlue('', 'portuguese')
eternalresponse = eternal_blue.diarize(audio, 2)

Here’s an example of how to use the EternalBlue class in a Flask application:

from eternalblue import EternalBlue

@app.route('/diarization', methods=['POST'])
def diarization():
    try:
        eternalresponse = {}
        if 'audio' in request.files:
            audio_file = request.files['audio']
            if audio_file.filename != '':
                save_path = os.path.join(AUDIO_PATH, audio_file.filename)
                audio_file.save(save_path)
                eternal_blue = EternalBlue('', 'portuguese')
                eternalresponse = eternal_blue.diarize(save_path, 2)
        return eternalresponse, 200
    except Exception as e:
        print(f"Error: {e}")
        return str(e), 500

Description

The EternalBlue class requires a Hugging Face API key, the language, and optionally the Whisper model in its constructor. The diarize method expects the path to the .wav audio file and the number of speakers.

Constructor Parameters

  • api_key: The Hugging Face API key as a string.

  • language: The language of the audio as a string.

  • whisper_model (optional): The Whisper model to use.

Method diarize

  • audio_file_path: The path to the .wav audio file as a string.

  • num_speakers: The number of speakers as an integer.

Expected Return

The diarize method returns a list of dictionaries containing metadata and transcriptions, formatted as follows:

[
    {
        "metadata": [
            {
                "audioname": "tester.wav",
                "time_type": "seconds"
            }
        ]
    },
    {
        "end": 5.984999999999999,
        "speaker_id": "SPEAKER_01",
        "start": 1.299,
        "text": " Is your name Bento Ferreira, then? Are you Brazilian? Yes, sir."
    },
    {
        "end": 5.934,
        "speaker_id": "SPEAKER_00",
        "start": 5.323,
        "text": " Yes, sir."
    },
    {
        "end": 8.498,
        "speaker_id": "SPEAKER_01",
        "start": 6.851,
        "text": " military police officer, That's it ?."
    },
    {
        "end": 13.829,
        "speaker_id": "SPEAKER_00",
        "start": 9.856,
        "text": " Thank God, after 35 years in the reserve."
    },
    {
        "end": 16.613,
        "speaker_id": "SPEAKER_00",
        "start": 15.645,
        "text": " Mr. Miguel. Miguel! "
    },
    {
        "end": 19.618000000000002,
        "speaker_id": "SPEAKER_00",
        "start": 16.969,
        "text": " Any relation to  James ?"
    },

]

This JSON structure contains the following information for each segment: - metadata: General information about the audio file. - speaker_id: The identifier for the speaker. - start: The start time of the speech segment in seconds. - end: The end time of the speech segment in seconds. - text: The transcribed text of the speech segment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eternalblue-1.2.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eternalblue-1.2.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file eternalblue-1.2.1.tar.gz.

File metadata

  • Download URL: eternalblue-1.2.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for eternalblue-1.2.1.tar.gz
Algorithm Hash digest
SHA256 567d1306132d2433a102552959fc9cdf87232f185854e808ed244164c0509653
MD5 d07756a0b35a288b8712d70054122a58
BLAKE2b-256 6a51f22da58cbbfc8018a3dc0a04dbc71d37e447e44bbfbe1b52d3deb06b1c16

See more details on using hashes here.

File details

Details for the file eternalblue-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: eternalblue-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for eternalblue-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02a9c15366f96fca3078bbc123983b7405a0dbe26a4bb537e70736f457f78c96
MD5 41432d5440148ebde34549b6025987ab
BLAKE2b-256 0cdd4a84ef237746689a51c52fc11c3a837c4a927cb8e178b36b220529f8e987

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page