
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
transcript-parser
Advanced tools
Parses plaintext speech/debate/radio transcripts into JavaScript objects.
Parses plaintext speech/debate/radio transcripts into JavaScript objects. It is still in early development. Pull requests are welcome.
Tested for Node.js versions >= 4.4.6
npm install transcript-parser
const fs = require('fs');
const TranscriptParser = require('transcript-parser');
const tp = new TranscriptParser();
//Synchronous example
const parsed = tp.parseOneSync(fs.readFileSync('transcript.txt', {encoding: 'UTF-8'}));
console.log(parsed);
//Asynchronous example
fs.readFile('transcript.txt', (err, data) => {
if(err) return console.error('Error:', err);
tp.parseOne(data, (err, parsed => {
if(err) return console.error('Error:', err);
console.log(parsed);
}));
});
//Stream example
const stream = fs.createReadStream('transcript.txt', 'utf8');
tp.parseStream(stream, (err, parsed) => {
if(err) return console.error('Error:', err);
console.log(parsed);
});
The constructor for TranscriptParser
accepts an options argument.
removeActions
true
removeAnnotations
true
[]
).removeTimestamps
true
removeAnnotations
is true[##:##:##]
format).removeUnknownSpeakers
false
none
.blacklist
[]
aliases
{}
Array
of the aliases' regular expressions as the value.{ "Mr. Robot": [ /[A-Z\ ]*SLATER[A-Z\ ]*/ ] }
The parseStream()
method parses a Stream
and returns an object representing it.
This is the preferred method for parsing streams asynchronously as it doesn't have to load the entire transcript into memory (unlike parseOne()
).
tp.parseOneSync(stream, callback)
stream
Readable
stream to read.callback(err, data)
The parseOneSync()
method parses a string and returns an object representing it.
tp.parseOneSync(transcript)
transcript
string
.The parseOne()
method parses a string and returns an object representing it.
tp.parseOne(transcript, callback)
transcript
string
.callback(err, data)
The resolveAliasesSync()
method resolves all aliases specified in the configuration passed to the TranscriptParser
's constructor (see above).
Renames the names in the order
list to match the new names in the transcript. Note that there is a signifigant performance penalty, so don't use this method unless you need it.
tp.resolveAliasesSync(data)
data
The resolveAliases()
method resolves all aliases specified in the configuration passed to the TranscriptParser
's constructor (see above).
Renames the names in the order
list to match the new names in the transcript. Note that there is a signifigant performance penalty, so don't use this method unless you need it.
tp.resolveAliases(data, callback)
data
callback(err, resolved)
FAQs
Parses plaintext speech/debate/radio transcripts into JavaScript objects.
We found that transcript-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.