Merge branch 'expose-version' (Fixes #2745)

This commit is contained in:
Reuben Morais 2020-02-13 17:35:13 +01:00
commit e9cf022e21
22 changed files with 51 additions and 41 deletions

View File

@ -49,5 +49,5 @@ C
.. doxygenfunction:: DS_FreeString .. doxygenfunction:: DS_FreeString
:project: deepspeech-c :project: deepspeech-c
.. doxygenfunction:: DS_PrintVersions .. doxygenfunction:: DS_Version
:project: deepspeech-c :project: deepspeech-c

View File

@ -22,7 +22,7 @@ Module exported methods
.. js:autofunction:: FreeMetadata .. js:autofunction:: FreeMetadata
.. js:autofunction:: printVersions .. js:autofunction:: Version
Metadata Metadata
-------- --------

View File

@ -55,7 +55,9 @@ void PrintHelp(const char* bin)
"\t--stream size\t\tRun in stream mode, output intermediate results\n" "\t--stream size\t\tRun in stream mode, output intermediate results\n"
"\t--help\t\t\tShow help\n" "\t--help\t\t\tShow help\n"
"\t--version\t\tPrint version and exits\n"; "\t--version\t\tPrint version and exits\n";
DS_PrintVersions(); char* version = DS_Version();
std::cerr << "DeepSpeech " << version << "\n";
DS_FreeString(version);
exit(1); exit(1);
} }
@ -143,7 +145,9 @@ bool ProcessArgs(int argc, char** argv)
} }
if (has_versions) { if (has_versions) {
DS_PrintVersions(); char* version = DS_Version();
std::cout << "DeepSpeech " << version << "\n";
DS_FreeString(version);
return false; return false;
} }

View File

@ -261,7 +261,14 @@ DS_CreateModel(const char* aModelPath,
{ {
*retval = nullptr; *retval = nullptr;
DS_PrintVersions(); std::cerr << "TensorFlow: " << tf_local_git_version() << std::endl;
std::cerr << "DeepSpeech: " << ds_git_version() << std::endl;
#ifdef __ANDROID__
LOGE("TensorFlow: %s", tf_local_git_version());
LOGD("TensorFlow: %s", tf_local_git_version());
LOGE("DeepSpeech: %s", ds_git_version());
LOGD("DeepSpeech: %s", ds_git_version());
#endif
if (!aModelPath || strlen(aModelPath) < 1) { if (!aModelPath || strlen(aModelPath) < 1) {
std::cerr << "No model specified, cannot continue." << std::endl; std::cerr << "No model specified, cannot continue." << std::endl;
@ -467,14 +474,7 @@ DS_FreeString(char* str)
free(str); free(str);
} }
void char*
DS_PrintVersions() { DS_Version() {
std::cerr << "TensorFlow: " << tf_local_git_version() << std::endl; return strdup(ds_version());
std::cerr << "DeepSpeech: " << ds_git_version() << std::endl;
#ifdef __ANDROID__
LOGE("TensorFlow: %s", tf_local_git_version());
LOGD("TensorFlow: %s", tf_local_git_version());
LOGE("DeepSpeech: %s", ds_git_version());
LOGD("DeepSpeech: %s", ds_git_version());
#endif
} }

View File

@ -288,10 +288,13 @@ DEEPSPEECH_EXPORT
void DS_FreeString(char* str); void DS_FreeString(char* str);
/** /**
* @brief Print version of this library and of the linked TensorFlow library. * @brief Return version of this library. The returned version is a semantic version
* (SemVer 2.0.0). The string returned must be freed with {@link DS_FreeString()}.
*
* @return The version string.
*/ */
DEEPSPEECH_EXPORT DEEPSPEECH_EXPORT
void DS_PrintVersions(); char* DS_Version();
#undef DEEPSPEECH_EXPORT #undef DEEPSPEECH_EXPORT

View File

@ -219,11 +219,12 @@ namespace DeepSpeechClient
} }
/// <summary> /// <summary>
/// Prints the versions of Tensorflow and DeepSpeech. /// Return version of this library. The returned version is a semantic version
/// (SemVer 2.0.0).
/// </summary> /// </summary>
public unsafe void PrintVersions() public unsafe string Version()
{ {
NativeImp.DS_PrintVersions(); return NativeImp.DS_Version().PtrToString();
} }
/// <summary> /// <summary>

View File

@ -10,9 +10,10 @@ namespace DeepSpeechClient.Interfaces
public interface IDeepSpeech : IDisposable public interface IDeepSpeech : IDisposable
{ {
/// <summary> /// <summary>
/// Prints the versions of Tensorflow and DeepSpeech. /// Return version of this library. The returned version is a semantic version
/// (SemVer 2.0.0).
/// </summary> /// </summary>
void PrintVersions(); unsafe string Version();
/// <summary> /// <summary>
/// Return the sample rate expected by the model. /// Return the sample rate expected by the model.

View File

@ -11,8 +11,9 @@ namespace DeepSpeechClient
internal static class NativeImp internal static class NativeImp
{ {
#region Native Implementation #region Native Implementation
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)] [DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl,
internal static extern void DS_PrintVersions(); CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern IntPtr DS_Version();
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)] [DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
internal unsafe static extern ErrorCodes DS_CreateModel(string aModelPath, internal unsafe static extern ErrorCodes DS_CreateModel(string aModelPath,

View File

@ -18,7 +18,7 @@ var VersionAction = function VersionAction(options) {
util.inherits(VersionAction, argparse.Action); util.inherits(VersionAction, argparse.Action);
VersionAction.prototype.call = function(parser) { VersionAction.prototype.call = function(parser) {
Ds.printVersions(); console.log('DeepSpeech ' + Ds.Version());
let runtime = 'Node'; let runtime = 'Node';
if (process.versions.electron) { if (process.versions.electron) {
runtime = 'Electron'; runtime = 'Electron';

View File

@ -36,6 +36,7 @@ using namespace node;
%newobject DS_SpeechToText; %newobject DS_SpeechToText;
%newobject DS_IntermediateDecode; %newobject DS_IntermediateDecode;
%newobject DS_FinishStream; %newobject DS_FinishStream;
%newobject DS_Version;
// convert double pointer retval in CreateModel to an output // convert double pointer retval in CreateModel to an output
%typemap(in, numinputs=0) ModelState **retval (ModelState *ret) { %typemap(in, numinputs=0) ModelState **retval (ModelState *ret) {

View File

@ -231,8 +231,8 @@ function FreeStream(stream) {
/** /**
* Print version of this library and of the linked TensorFlow library on standard output. * Print version of this library and of the linked TensorFlow library on standard output.
*/ */
function printVersions() { function Version() {
return binding.PrintVersions(); return binding.Version();
} }
@ -300,7 +300,7 @@ module.exports = {
Model: Model, Model: Model,
Metadata: Metadata, Metadata: Metadata,
MetadataItem: MetadataItem, MetadataItem: MetadataItem,
printVersions: printVersions, Version: Version,
FreeModel: FreeModel, FreeModel: FreeModel,
FreeStream: FreeStream, FreeStream: FreeStream,
FreeMetadata: FreeMetadata FreeMetadata: FreeMetadata

View File

@ -20,7 +20,7 @@ if platform.system().lower() == "windows":
import deepspeech import deepspeech
# rename for backwards compatibility # rename for backwards compatibility
from deepspeech.impl import PrintVersions as printVersions from deepspeech.impl import Version as version
class Model(object): class Model(object):
""" """

View File

@ -10,7 +10,7 @@ import sys
import wave import wave
import json import json
from deepspeech import Model, printVersions from deepspeech import Model, version
from timeit import default_timer as timer from timeit import default_timer as timer
try: try:
@ -80,7 +80,7 @@ class VersionAction(argparse.Action):
super(VersionAction, self).__init__(nargs=0, *args, **kwargs) super(VersionAction, self).__init__(nargs=0, *args, **kwargs)
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
printVersions() print('DeepSpeech ', version())
exit(0) exit(0)

View File

@ -62,6 +62,7 @@ import_array();
%newobject DS_SpeechToText; %newobject DS_SpeechToText;
%newobject DS_IntermediateDecode; %newobject DS_IntermediateDecode;
%newobject DS_FinishStream; %newobject DS_FinishStream;
%newobject DS_Version;
%rename ("%(strip:[DS_])s") ""; %rename ("%(strip:[DS_])s") "";

View File

@ -28,8 +28,6 @@ android_setup_emulator "${arm_flavor}" "${api_level}"
android_setup_ndk_data android_setup_ndk_data
check_tensorflow_version
run_tflite_basic_inference_tests run_tflite_basic_inference_tests
android_stop_emulator android_stop_emulator

View File

@ -252,10 +252,10 @@ assert_deepspeech_version()
assert_not_present "$1" "DeepSpeech: unknown" assert_not_present "$1" "DeepSpeech: unknown"
} }
check_tensorflow_version() check_versions()
{ {
set +e set +e
ds_help=$(${DS_BINARY_PREFIX}deepspeech 2>&1 1>/dev/null) ds_help=$(${DS_BINARY_PREFIX}deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>&1 1>/dev/null)
set -e set -e
assert_tensorflow_version "${ds_help}" assert_tensorflow_version "${ds_help}"

View File

@ -17,6 +17,6 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_prod_inference_tests "${bitrate}" run_prod_inference_tests "${bitrate}"

View File

@ -11,7 +11,7 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_all_inference_tests run_all_inference_tests

View File

@ -16,7 +16,7 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_all_inference_tests run_all_inference_tests

View File

@ -18,6 +18,6 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_prodtflite_inference_tests "${bitrate}" run_prodtflite_inference_tests "${bitrate}"

View File

@ -16,6 +16,6 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_tflite_basic_inference_tests run_tflite_basic_inference_tests

View File

@ -11,6 +11,6 @@ download_material "${TASKCLUSTER_TMP_DIR}/ds"
export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH export PATH=${TASKCLUSTER_TMP_DIR}/ds/:$PATH
check_tensorflow_version check_versions
run_basic_inference_tests run_basic_inference_tests