Category description and use cases
Segmentation MGMs detect when silence, speech, and/or music occur in an audio file. This information may be interesting in its own right for determining how much of an object in an archive has content (e.g. is half the tape silence?). Segment data could also be used to route files (or parts of files) to different MGMs based on the content (for example, sending the speech portions into a workflow that includes STT and the music portions into a music workflow).
Note: these tools do not split the audio files themselves, only output timestamped labels for the contents of a segment. Splitting would need to be handled by another tool, such as ffmpeg.
Workflow example:
Output standard
Summary: An array of segments, each with a label, start, and end. Start and end are timestamps in seconds. The label may be one of: "speech", "music", "silence." If the label is "speech," a gender" may be specified as either "male" or "female."
Element | Datatype | Obligation | Definition |
media | object | required | Wrapper for metadata about the source media file. |
media.filename | string | required | Filename of the source file. |
media.duration | string | required | The duration of the source file audio. |
numSpeakers | integer | optional | Number of speakers (if used for diarization). |
segments | array | required | Wrapper for segments of silence, speech, or audio. |
segments[*] | object | optional | A segment of silence, speech, or audio. |
segments[*].label | string | required | The type of segment: silence, speech, or audio. |
segments[*].start | string | required | Start time in seconds. |
segments[*].end | string | required | End time in seconds. |
segments[*].gender | string | optional | The classified gender of the speaker. |
segments[*].speakerLabel | string | optional | Speaker label from speaker diarization. |
Sample output
Recommended tool(s)
inaSpeechSegmenter
Official documentation: GitHub
Language: Python
Description: inaSpeechSegmenter detects music, speech, noise, silence ("no energy") and the apparent gender of the speaker. Zones of speech over music are usually tagged as speech but sometimes as music.
Cost: Free (open source)
Social impact: Trained on French-language samples, so its idea of what male and female voices sound like are based on an unknown sample of French speakers. From initial testing, the results have been more or less accurate for our samples in English, but this is an important note.
Notes:
Installation & requirements
Requires ffmpeg and TensorFlow
Install via pip:
pip install inaSpeechSegmenter
Parameters
None
Because inaSpeechSegmenter does not have any parameters for the minimum length of a segment or maximum length of silence allowed within a speech/music segment, it may be beneficial to add another step in the workflow (or built in to the ina adapter) that allows the output from ina to be filtered/altered based on such parameters.
Input formats
All media formats accepted by ffmpeg (wav, mp3, mp4, etc.)
AMP Implementation notes
In order to create "smoother" segments for our use cases, segments of noise and silence should be a minimum of 10 seconds. Short segments should be folded into the previous segment. This removes very brief segments of silence in between words/sentences/speakers to produce higher-level regions of speech, silence, noise, and music.
For use in sending just regions of speech through speech-to-text MGMs, remove segments of noise and silence that are longer than 1 minute (timestamps will be readjusted later) to cut down on transcription processing time.
Example Usage
from inaSpeechSegmenter import Segmenter seg = Segmenter() segmentation = seg("path/to/file.wav") for s in segmentation: label = s[0] start = s[1] end = s[2] print("Detected {} from {} seconds to {} seconds".format(label, start, end))
Example Output
# Output has been printed in the order start, end, label 0.0 23.76 Music 23.78 28.080000000000002 NOACTIVITY 28.080000000000002 36.6 Music 36.62 37.2 NOACTIVITY 37.2 38.04 Music 38.06 38.9 NOACTIVITY 38.9 44.72 Music 44.74 46.04 NOACTIVITY 46.04 46.58 Music 46.6 47.56 NOACTIVITY 47.56 254.24 Music 254.24 255.26000000000002 Female 255.28 274.82 Music 274.84000000000003 275.32 NOACTIVITY 275.32 277.90000000000003 Music 277.92 278.74 NOACTIVITY 278.74 279.88 Female 279.90000000000003 345.0 Music 345.02 347.5 NOACTIVITY 347.5 355.42 Music 355.44 356.34000000000003 NOACTIVITY 356.34000000000003 372.66 Music 372.68 378.12 NOACTIVITY 378.12 395.2 Music
Other evaluated tools
pyannote-audio
Official documentation: GitHub
Language: Python
Description: "Neural building blocks for speaker diarization: speech activity detection, speaker change detection, overlapped speech detection, speaker embedding"
Cost: Free (open source)
Notes: Seems to be somewhat accurate in detecting when speech occurs. However, it only identifies speech segments, not music or silence like we would prefer. Primarily used for detecting different speakers, which is not something we have a particular use case for.
Installation & requirements
Install via pip (pyannote.audio)
Requires Python 3.7 on Linux/MacOS
Example Usage
Example Output
4.65 4.66 Speech 4.67 4.68 Speech 4.69 4.7 Speech 4.71 4.72 Speech 4.73 4.74 Speech 4.75 4.76 Speech 4.7700000000000005 4.78 Speech 4.79 4.8 Speech 4.8100000000000005 4.82 Speech 4.83 4.84 Speech 4.8500000000000005 4.86 Speech 4.87 4.88 Speech 4.89 4.9 Speech 4.91 4.92 Speech 4.93 4.94 Speech 4.95 4.96 Speech 4.97 4.98 Speech 4.99 5.0 Speech 6.57 6.58 Speech 7.04 7.05 Speech 7.0600000000000005 7.07 Speech
LIUM SpkDiarization
Official documentation: LIUM SpkDiarization
Language: Java, run via command line.
Description: "LIUM_SpkDiarization comprises a full set of tools to create a complete system for speaker diarization, going from the audio signal to speaker clustering based on the CLR/NCLR metrics. These tools include MFCC computation, speech/non-speech detection, and speaker diarization methods."
Cost: Free (open source)
Notes: Like pyannotate-audio, this is primarily for speaker diarization rather than the kind of segmentation we want. However, it is fairly successful at identifying where speech occurs. We don't like that it assumes a gender of the speaker, though we would just never use that information if we were to use the tool.
Installation & requirements
Download JAR (see documentation)
Input formats
All media formats accepted by ffmpeg (wav, mp3, mp4, etc.)
Example Usage
$ /usr/bin/java -Xmx2024m -jar ./LIUM_SpkDiarization.jar --fInputMask=./fileName.wav --sOutputMask=./fileName.seg --doCEClustering fileName
Example Output
In addition to start and length of speech segment, this outputs the assumed gender of the speaker (M/F) and a speaker number (S0, S1...)
astinPatten 1 0 1004 M S U S0 astinPatten 1 1004 292 M S U S0 astinPatten 1 1296 539 M S U S0 astinPatten 1 1835 1282 M S U S0 astinPatten 1 3117 722 M S U S0 astinPatten 1 3839 953 M S U S0 astinPatten 1 4792 623 M S U S0 astinPatten 1 5415 1324 M S U S0 astinPatten 1 6739 840 M S U S0 astinPatten 1 7579 1403 M S U S0 astinPatten 1 8982 421 M S U S1 astinPatten 1 9403 1504 M S U S0 astinPatten 1 10907 1099 M S U S0 astinPatten 1 12006 372 M S U S0
Evaluation summary
Each tool was tested with a variety of (shorter) samples pulled from our sample collections files. Outputs were reviewed using timed labels in Audacity. Ultimately, only INA offers the all-in-one segmentation we're looking for. If at a later time we determined a use case for diarization, we would return to one of the other tools listed here.