Rename metadata probability field to confidence
This commit is contained in:
parent
fcb9bf6d9f
commit
0ac498bc50
|
@ -350,7 +350,7 @@ JSONOutput(Metadata* metadata)
|
||||||
std::vector<meta_word> words = WordsFromMetadata(metadata);
|
std::vector<meta_word> words = WordsFromMetadata(metadata);
|
||||||
|
|
||||||
std::ostringstream out_string;
|
std::ostringstream out_string;
|
||||||
out_string << R"({"metadata":{"confidence":)" << metadata->probability << R"(},"words":[)";
|
out_string << R"({"metadata":{"confidence":)" << metadata->confidence << R"(},"words":[)";
|
||||||
|
|
||||||
for (int i = 0; i < words.size(); i++) {
|
for (int i = 0; i < words.size(); i++) {
|
||||||
meta_word w = words[i];
|
meta_word w = words[i];
|
||||||
|
|
|
@ -51,14 +51,14 @@ def ctc_beam_search_decoder(probs_seq,
|
||||||
:param scorer: External scorer for partially decoded sentence, e.g. word
|
:param scorer: External scorer for partially decoded sentence, e.g. word
|
||||||
count or language model.
|
count or language model.
|
||||||
:type scorer: Scorer
|
:type scorer: Scorer
|
||||||
:return: List of tuples of log probability and sentence as decoding
|
:return: List of tuples of confidence and sentence as decoding
|
||||||
results, in descending order of the probability.
|
results, in descending order of the confidence.
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
beam_results = swigwrapper.ctc_beam_search_decoder(
|
beam_results = swigwrapper.ctc_beam_search_decoder(
|
||||||
probs_seq, alphabet.config_file(), beam_size, cutoff_prob, cutoff_top_n,
|
probs_seq, alphabet.config_file(), beam_size, cutoff_prob, cutoff_top_n,
|
||||||
scorer)
|
scorer)
|
||||||
beam_results = [(res.probability, alphabet.decode(res.tokens)) for res in beam_results]
|
beam_results = [(res.confidence, alphabet.decode(res.tokens)) for res in beam_results]
|
||||||
return beam_results
|
return beam_results
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,15 +93,15 @@ def ctc_beam_search_decoder_batch(probs_seq,
|
||||||
:param scorer: External scorer for partially decoded sentence, e.g. word
|
:param scorer: External scorer for partially decoded sentence, e.g. word
|
||||||
count or language model.
|
count or language model.
|
||||||
:type scorer: Scorer
|
:type scorer: Scorer
|
||||||
:return: List of tuples of log probability and sentence as decoding
|
:return: List of tuples of confidence and sentence as decoding
|
||||||
results, in descending order of the probability.
|
results, in descending order of the confidence.
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
batch_beam_results = swigwrapper.ctc_beam_search_decoder_batch(
|
batch_beam_results = swigwrapper.ctc_beam_search_decoder_batch(
|
||||||
probs_seq, seq_lengths, alphabet.config_file(), beam_size, num_processes,
|
probs_seq, seq_lengths, alphabet.config_file(), beam_size, num_processes,
|
||||||
cutoff_prob, cutoff_top_n, scorer)
|
cutoff_prob, cutoff_top_n, scorer)
|
||||||
batch_beam_results = [
|
batch_beam_results = [
|
||||||
[(res.probability, alphabet.decode(res.tokens)) for res in beam_results]
|
[(res.confidence, alphabet.decode(res.tokens)) for res in beam_results]
|
||||||
for beam_results in batch_beam_results
|
for beam_results in batch_beam_results
|
||||||
]
|
]
|
||||||
return batch_beam_results
|
return batch_beam_results
|
||||||
|
|
|
@ -46,7 +46,7 @@ std::vector<Output> get_beam_search_result(
|
||||||
for (size_t i = 0; i < top_paths && i < prefixes.size(); ++i) {
|
for (size_t i = 0; i < top_paths && i < prefixes.size(); ++i) {
|
||||||
Output output;
|
Output output;
|
||||||
prefixes[i]->get_path_vec(output.tokens, output.timesteps);
|
prefixes[i]->get_path_vec(output.tokens, output.timesteps);
|
||||||
output.probability = -prefixes[i]->approx_ctc;
|
output.confidence = -prefixes[i]->approx_ctc;
|
||||||
output_vecs.push_back(output);
|
output_vecs.push_back(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* for each token in the beam search output
|
* for each token in the beam search output
|
||||||
*/
|
*/
|
||||||
struct Output {
|
struct Output {
|
||||||
double probability;
|
double confidence;
|
||||||
std::vector<int> tokens;
|
std::vector<int> tokens;
|
||||||
std::vector<int> timesteps;
|
std::vector<int> timesteps;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,8 +30,8 @@ typedef struct MetadataItem {
|
||||||
typedef struct Metadata {
|
typedef struct Metadata {
|
||||||
MetadataItem* items;
|
MetadataItem* items;
|
||||||
int num_items;
|
int num_items;
|
||||||
// Approximated probability (confidence value) for this transcription.
|
// Approximated confidence value for this transcription.
|
||||||
double probability;
|
double confidence;
|
||||||
} Metadata;
|
} Metadata;
|
||||||
|
|
||||||
enum DeepSpeech_Error_Codes
|
enum DeepSpeech_Error_Codes
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace DeepSpeechClient.Extensions
|
||||||
var metaData = (Metadata)Marshal.PtrToStructure(intPtr, typeof(Metadata));
|
var metaData = (Metadata)Marshal.PtrToStructure(intPtr, typeof(Metadata));
|
||||||
|
|
||||||
managedMetaObject.Items = new Models.MetadataItem[metaData.num_items];
|
managedMetaObject.Items = new Models.MetadataItem[metaData.num_items];
|
||||||
managedMetaObject.Probability = metaData.probability;
|
managedMetaObject.Confidence = metaData.confidence;
|
||||||
|
|
||||||
|
|
||||||
//we need to manually read each item from the native ptr using its size
|
//we need to manually read each item from the native ptr using its size
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
public class Metadata
|
public class Metadata
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Approximated probability (confidence value) for this transcription.
|
/// Approximated confidence value for this transcription.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Probability { get; set; }
|
public double Confidence { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of metada items containing char, timespet, and time offset.
|
/// List of metada items containing char, timespet, and time offset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -15,8 +15,8 @@ namespace DeepSpeechClient.Structs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal unsafe int num_items;
|
internal unsafe int num_items;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Approximated probability (confidence value) for this transcription.
|
/// Approximated confidence value for this transcription.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal unsafe double probability;
|
internal unsafe double confidence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ ModelState::decode_metadata(const DecoderState& state)
|
||||||
|
|
||||||
std::unique_ptr<Metadata> metadata(new Metadata());
|
std::unique_ptr<Metadata> metadata(new Metadata());
|
||||||
metadata->num_items = out[0].tokens.size();
|
metadata->num_items = out[0].tokens.size();
|
||||||
metadata->probability = out[0].probability;
|
metadata->confidence = out[0].confidence;
|
||||||
|
|
||||||
std::unique_ptr<MetadataItem[]> items(new MetadataItem[metadata->num_items]());
|
std::unique_ptr<MetadataItem[]> items(new MetadataItem[metadata->num_items]());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue