├── Binaries ├── 4_11 │ └── Win64 │ │ └── UE4Editor-SpeechRecognition.dll └── 4_12 │ ├── Mac │ ├── UE4Editor-SpeechRecognition.dSYM │ ├── UE4Editor-SpeechRecognition.dylib │ └── UE4Editor.modules │ └── Win64 │ └── UE4Editor-SpeechRecognition.dll ├── License.md ├── Plugins └── SpeechRecognition │ ├── Resources │ └── Icon128.png │ ├── Source │ └── SpeechRecognition │ │ ├── Private │ │ ├── SpeechRecognition.cpp │ │ ├── SpeechRecognitionActor.cpp │ │ └── SpeechRecognitionWorker.cpp │ │ ├── Public │ │ ├── ISpeechRecognition.h │ │ ├── SpeechRecognition.h │ │ ├── SpeechRecognitionActor.h │ │ └── SpeechRecognitionWorker.h │ │ └── SpeechRecognition.Build.cs │ ├── SpeechRecognition.uplugin │ └── ThirdParty │ ├── OpenAL │ ├── libcommon.a │ ├── libopenal.1.17.2.dylib │ ├── libopenal.1.dylib │ └── libopenal.dylib │ ├── PocketSphinx │ ├── Includes │ │ ├── Makefile.am │ │ ├── cmdln_macro.h │ │ ├── pocketsphinx.h │ │ ├── pocketsphinx_export.h │ │ ├── ps_lattice.h │ │ ├── ps_mllr.h │ │ └── ps_search.h │ └── Libraries │ │ ├── osx │ │ ├── libpocketsphinx.3.dylib │ │ ├── libpocketsphinx.a │ │ └── libpocketsphinx.dylib │ │ ├── x64 │ │ ├── pocketsphinx.dll │ │ └── pocketsphinx.lib │ │ └── x86 │ │ ├── pocketsphinx.dll │ │ └── pocketsphinx.lib │ └── SphinxBase │ ├── Includes │ ├── Makefile.am │ ├── android │ │ ├── config.h │ │ └── sphinx_config.h │ ├── sphinx_config.h.in │ ├── sphinxbase │ │ ├── Makefile.am │ │ ├── ad.h │ │ ├── agc.h │ │ ├── bio.h │ │ ├── bitvec.h │ │ ├── byteorder.h │ │ ├── case.h │ │ ├── ckd_alloc.h │ │ ├── clapack_lite.h │ │ ├── cmd_ln.h │ │ ├── cmn.h │ │ ├── err.h │ │ ├── f2c.h │ │ ├── fe.h │ │ ├── feat.h │ │ ├── filename.h │ │ ├── fixpoint.h │ │ ├── fsg_model.h │ │ ├── genrand.h │ │ ├── glist.h │ │ ├── hash_table.h │ │ ├── heap.h │ │ ├── huff_code.h │ │ ├── jsgf.h │ │ ├── listelem_alloc.h │ │ ├── logmath.h │ │ ├── matrix.h │ │ ├── mmio.h │ │ ├── mulaw.h │ │ ├── ngram_model.h │ │ ├── pio.h │ │ ├── prim_type.h │ │ ├── profile.h │ │ ├── sbthread.h │ │ ├── sphinxbase_export.h │ │ ├── strfuncs.h │ │ └── yin.h │ ├── win32 │ │ ├── config.h │ │ └── sphinx_config.h │ └── wince │ │ ├── assert.h │ │ ├── config.h │ │ ├── errno.h │ │ └── sphinx_config.h │ └── Libraries │ ├── osx │ ├── libcommon.a │ ├── libopenal.1.17.2.dylib │ ├── libopenal.1.dylib │ ├── libopenal.dylib │ ├── libsphinxad.3.dylib │ ├── libsphinxad.a │ ├── libsphinxad.dylib │ ├── libsphinxad.la │ ├── libsphinxbase.3.dylib │ ├── libsphinxbase.a │ ├── libsphinxbase.dylib │ └── libsphinxbase.la │ ├── x64 │ ├── sphinxbase.dll │ └── sphinxbase.lib │ └── x86 │ ├── sphinxbase.dll │ └── sphinxbase.lib ├── README.md └── _other └── PocketSphinx ├── include └── ps_search.h └── src └── libpocketsphinx ├── kws_search.c ├── kws_search.h └── pocketsphinx.c /Binaries/4_11/Win64/UE4Editor-SpeechRecognition.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Binaries/4_11/Win64/UE4Editor-SpeechRecognition.dll -------------------------------------------------------------------------------- /Binaries/4_12/Mac/UE4Editor-SpeechRecognition.dSYM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Binaries/4_12/Mac/UE4Editor-SpeechRecognition.dSYM -------------------------------------------------------------------------------- /Binaries/4_12/Mac/UE4Editor-SpeechRecognition.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Binaries/4_12/Mac/UE4Editor-SpeechRecognition.dylib -------------------------------------------------------------------------------- /Binaries/4_12/Mac/UE4Editor.modules: -------------------------------------------------------------------------------- 1 | { 2 | "Changelist" : 3039270, 3 | "BuildId" : "7e528244-4b20-4e2a-93de-e7249d8fdf0c", 4 | "Modules" : 5 | { 6 | "SpeechRecognition" : "UE4Editor-SpeechRecognition.dylib" 7 | } 8 | } -------------------------------------------------------------------------------- /Binaries/4_12/Win64/UE4Editor-SpeechRecognition.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Binaries/4_12/Win64/UE4Editor-SpeechRecognition.dll -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/Resources/Icon128.png -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Private/SpeechRecognition.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SpeechRecognition.h" 4 | 5 | IMPLEMENT_MODULE( FSpeechRecognition, SpeechRecognition ) 6 | 7 | void FSpeechRecognition::StartupModule() 8 | { 9 | if(PLATFORM_WINDOWS) { 10 | //Search project plugins folder for Dll 11 | FString dllName = "SphinxBase.dll"; 12 | if (SearchForDllPath(FPaths::GamePluginsDir(), dllName)) 13 | { 14 | } 15 | else if (SearchForDllPath(FPaths::EnginePluginsDir(), dllName)) //Failed in project dir, try engine plugins dir 16 | { 17 | } 18 | else 19 | { 20 | //Stop loading - plugin required DLL to load successfully 21 | checkf(false, TEXT("Failed to load dll")); 22 | } 23 | 24 | dllName = "PocketSphinx.dll"; 25 | if (SearchForDllPath(FPaths::GamePluginsDir(), dllName)) 26 | { 27 | } 28 | else if (SearchForDllPath(FPaths::EnginePluginsDir(), dllName)) //Failed in project dir, try engine plugins dir 29 | { 30 | } 31 | else 32 | { 33 | //Stop loading - plugin required DLL to load successfully 34 | checkf(false, TEXT("Failed to load dll")); 35 | } 36 | } 37 | } 38 | 39 | bool FSpeechRecognition::SearchForDllPath(FString _searchBase, FString _dllName) 40 | { 41 | //Search Plugins folder for an instance of Dll.dll, and add to platform search path 42 | TArray directoriesToSkip; 43 | IPlatformFile &PlatformFile = FPlatformFileManager::Get().GetPlatformFile(); 44 | FLocalTimestampDirectoryVisitor Visitor(PlatformFile, directoriesToSkip, directoriesToSkip, false); 45 | PlatformFile.IterateDirectory(*_searchBase, Visitor); 46 | 47 | for (TMap::TIterator TimestampIt(Visitor.FileTimes); TimestampIt; ++TimestampIt) 48 | { 49 | const FString file = TimestampIt.Key(); 50 | const FString filePath = FPaths::GetPath(file); 51 | const FString fileName = FPaths::GetCleanFilename(file); 52 | char* filename_str = TCHAR_TO_ANSI(*fileName); 53 | if (fileName.Equals(_dllName, ESearchCase::IgnoreCase)) 54 | { 55 | FPlatformProcess::AddDllDirectory(*filePath); // only load dll when needed for use. Broken with 4.11. 56 | FPlatformProcess::GetDllHandle(*file); // auto-load dll with plugin - needed as 4.11 breaks above line. 57 | return true; 58 | } 59 | } 60 | return false; 61 | } 62 | 63 | void FSpeechRecognition::ShutdownModule() 64 | { 65 | //TODO 66 | } 67 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Private/SpeechRecognitionActor.cpp: -------------------------------------------------------------------------------- 1 | #include "SpeechRecognition.h" 2 | #include "SpeechRecognitionActor.h" 3 | 4 | #define SPEECHRECOGNITIONPLUGIN ISpeechRecognition::Get() 5 | 6 | bool ASpeechRecognitionActor::Init(ESpeechRecognitionLanguage language) 7 | { 8 | // terminate any existing thread 9 | if (listenerThread != NULL) 10 | Shutdown(); 11 | 12 | // start listener thread 13 | listenerThread = new FSpeechRecognitionWorker(); 14 | TArray dictionaryList; 15 | listenerThread->SetLanguage(language); 16 | bool threadSuccess = listenerThread->StartThread(this); 17 | return threadSuccess; 18 | } 19 | 20 | bool ASpeechRecognitionActor::SetConfigParam(FString param, ESpeechRecognitionParamType type, FString value) 21 | { 22 | if (listenerThread != NULL) { 23 | bool returnVal = listenerThread->SetConfigParam(param, type, value); 24 | return returnVal; 25 | } 26 | return false; 27 | } 28 | 29 | bool ASpeechRecognitionActor::Shutdown() 30 | { 31 | if (listenerThread != NULL) { 32 | listenerThread->ShutDown(); 33 | listenerThread = NULL; 34 | return true; 35 | } 36 | else{ 37 | return false; 38 | } 39 | } 40 | 41 | /************************** 42 | // Change recognition methods 43 | **************************/ 44 | bool ASpeechRecognitionActor::EnableKeywordMode(TArray wordList) 45 | { 46 | if (listenerThread != NULL) { 47 | return listenerThread->EnableKeywordMode(wordList); 48 | } 49 | return false; 50 | } 51 | 52 | bool ASpeechRecognitionActor::EnableGrammarMode(FString grammarName) 53 | { 54 | if (listenerThread != NULL) { 55 | return listenerThread->EnableGrammarMode(grammarName); 56 | } 57 | return false; 58 | } 59 | 60 | /************************** 61 | // Callback methods 62 | **************************/ 63 | void ASpeechRecognitionActor::WordsSpoken_trigger(FWordsSpokenSignature delegate_method, FRecognisedPhrases text) 64 | { 65 | delegate_method.Broadcast(text); 66 | } 67 | 68 | void ASpeechRecognitionActor::WordsSpoken_method(FRecognisedPhrases text) 69 | { 70 | FSimpleDelegateGraphTask::CreateAndDispatchWhenReady 71 | ( 72 | FSimpleDelegateGraphTask::FDelegate::CreateStatic(&WordsSpoken_trigger, OnWordsSpoken, text) 73 | , TStatId() 74 | , nullptr 75 | , ENamedThreads::GameThread 76 | ); 77 | } 78 | 79 | void ASpeechRecognitionActor::UnknownPhrase_trigger(FUnknownPhraseSignature delegate_method) 80 | { 81 | delegate_method.Broadcast(); 82 | } 83 | 84 | void ASpeechRecognitionActor::UnknownPhrase_method() 85 | { 86 | FSimpleDelegateGraphTask::CreateAndDispatchWhenReady 87 | ( 88 | FSimpleDelegateGraphTask::FDelegate::CreateStatic(&UnknownPhrase_trigger, OnUnknownPhrase) 89 | , TStatId() 90 | , nullptr 91 | , ENamedThreads::GameThread 92 | ); 93 | } 94 | 95 | void ASpeechRecognitionActor::StartedSpeaking_trigger(FStartedSpeakingSignature delegate_method) 96 | { 97 | delegate_method.Broadcast(); 98 | } 99 | 100 | void ASpeechRecognitionActor::StartedSpeaking_method() 101 | { 102 | FSimpleDelegateGraphTask::CreateAndDispatchWhenReady 103 | ( 104 | FSimpleDelegateGraphTask::FDelegate::CreateStatic(&StartedSpeaking_trigger, OnStartedSpeaking) 105 | , TStatId() 106 | , nullptr 107 | , ENamedThreads::GameThread 108 | ); 109 | } 110 | 111 | void ASpeechRecognitionActor::StoppedSpeaking_trigger(FStoppedSpeakingSignature delegate_method) 112 | { 113 | delegate_method.Broadcast(); 114 | } 115 | 116 | void ASpeechRecognitionActor::StoppedSpeaking_method() 117 | { 118 | FSimpleDelegateGraphTask::CreateAndDispatchWhenReady 119 | ( 120 | FSimpleDelegateGraphTask::FDelegate::CreateStatic(&StoppedSpeaking_trigger, OnStoppedSpeaking) 121 | , TStatId() 122 | , nullptr 123 | , ENamedThreads::GameThread 124 | ); 125 | } 126 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Public/ISpeechRecognition.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "SpeechRecognition.h" 6 | #include "ModuleManager.h" 7 | 8 | class ISpeechRecognition : public IModuleInterface 9 | { 10 | 11 | int32 instanceCtr; 12 | 13 | public: 14 | 15 | UFUNCTION(BlueprintCallable, Category = "Audio") 16 | static inline ISpeechRecognition& Get() 17 | { 18 | return FModuleManager::LoadModuleChecked< ISpeechRecognition >( "SpeechRecognition" ); 19 | } 20 | 21 | UFUNCTION(BlueprintCallable, Category = "Audio") 22 | static inline bool IsAvailable() 23 | { 24 | return FModuleManager::Get().IsModuleLoaded("SpeechRecognition"); 25 | } 26 | 27 | UFUNCTION(BlueprintCallable, Category = "Audio") 28 | int32 GetInstanceCounter() 29 | { 30 | return instanceCtr++; 31 | } 32 | 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Public/SpeechRecognition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine.h" 4 | #include "Kismet/GameplayStatics.h" 5 | #include "ISpeechRecognition.h" 6 | #include "SpeechRecognition.generated.h" 7 | 8 | //Common structures and enumerations 9 | USTRUCT(BlueprintType) 10 | struct FRecognisedPhrases 11 | { 12 | GENERATED_USTRUCT_BODY() 13 | 14 | UPROPERTY(BlueprintReadWrite) 15 | TArray phrases; 16 | 17 | // default constructor 18 | FRecognisedPhrases() { 19 | } 20 | }; 21 | 22 | UENUM(BlueprintType) 23 | enum class ESpeechRecognitionMode : uint8 24 | { 25 | VE_KEYWORD UMETA(DisplayName = "Keyword Spotting"), 26 | VE_GRAMMAR UMETA(DisplayName = "Grammar") 27 | }; 28 | 29 | UENUM(BlueprintType) 30 | enum class ESpeechRecognitionParamType : uint8 31 | { 32 | VE_FLOAT UMETA(DisplayName = "Float"), 33 | VE_BOOLEAN UMETA(DisplayName = "Boolean"), 34 | VE_STRING UMETA(DisplayName = "String"), 35 | VE_INTEGER UMETA(DisplayName = "Integer") 36 | }; 37 | 38 | UENUM(BlueprintType) 39 | enum class ESpeechRecognitionLanguage : uint8 40 | { 41 | VE_English UMETA(DisplayName = "English"), 42 | VE_Chinese UMETA(DisplayName = "Chinese"), 43 | VE_French UMETA(DisplayName = "French") 44 | }; 45 | 46 | UENUM(BlueprintType) 47 | enum class EPhraseRecognitionTolerance : uint8 48 | { 49 | VE_1 UMETA(DisplayName = "V1"), 50 | VE_2 UMETA(DisplayName = "V2"), 51 | VE_3 UMETA(DisplayName = "V3"), 52 | VE_4 UMETA(DisplayName = "V4"), 53 | VE_5 UMETA(DisplayName = "V5"), 54 | VE_6 UMETA(DisplayName = "V6"), 55 | VE_7 UMETA(DisplayName = "V7"), 56 | VE_8 UMETA(DisplayName = "V8"), 57 | VE_9 UMETA(DisplayName = "V9"), 58 | VE_10 UMETA(DisplayName = "V10") 59 | }; 60 | 61 | USTRUCT(BlueprintType) 62 | struct FRecognitionPhrase 63 | { 64 | GENERATED_USTRUCT_BODY() 65 | 66 | UPROPERTY(BlueprintReadWrite) 67 | FString phrase; 68 | 69 | UPROPERTY(BlueprintReadWrite) 70 | EPhraseRecognitionTolerance tolerance; 71 | 72 | // default constructor 73 | FRecognitionPhrase() { 74 | } 75 | 76 | // if you wish to only provide a phrase 77 | FRecognitionPhrase(FString phrase) { 78 | this->phrase = phrase; 79 | tolerance = EPhraseRecognitionTolerance::VE_5; 80 | } 81 | 82 | // if you wish to specify both a phrase, and a tolerance setting 83 | FRecognitionPhrase(FString phrase, EPhraseRecognitionTolerance tolerance) { 84 | this->phrase = phrase; 85 | this->tolerance = tolerance; 86 | } 87 | }; 88 | 89 | class FSpeechRecognition :public ISpeechRecognition 90 | { 91 | 92 | public: 93 | 94 | /** IModuleInterface implementation */ 95 | virtual void StartupModule() override; 96 | virtual void ShutdownModule() override; 97 | 98 | /** Search for a dll to be loaded dynamically */ 99 | bool SearchForDllPath(FString _searchBase, FString _dllName); 100 | 101 | }; 102 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Public/SpeechRecognitionActor.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "SpeechRecognitionWorker.h" 5 | #include "SpeechRecognition.h" 6 | #include "TaskGraphInterfaces.h" 7 | #include "SpeechRecognitionActor.generated.h" 8 | 9 | DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartedSpeakingSignature); 10 | DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStoppedSpeakingSignature); 11 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWordsSpokenSignature, FRecognisedPhrases, Text); 12 | DECLARE_DYNAMIC_MULTICAST_DELEGATE(FUnknownPhraseSignature); 13 | 14 | UCLASS(BlueprintType, Blueprintable) 15 | class SPEECHRECOGNITION_API ASpeechRecognitionActor : public AActor 16 | { 17 | GENERATED_BODY() 18 | 19 | private: 20 | 21 | int32 instanceCtr; 22 | 23 | FSpeechRecognitionWorker* listenerThread; 24 | 25 | static void WordsSpoken_trigger(FWordsSpokenSignature delegate_method, FRecognisedPhrases text); 26 | static void UnknownPhrase_trigger(FUnknownPhraseSignature delegate_method); 27 | static void StartedSpeaking_trigger(FStartedSpeakingSignature delegate_method); 28 | static void StoppedSpeaking_trigger(FStoppedSpeakingSignature delegate_method); 29 | 30 | public: 31 | 32 | //Methods to switch recognition modes 33 | UFUNCTION(BlueprintCallable, Category = "Audio", meta = (DisplayName = "Enable Keyword Mode", Keywords = "Speech Recognition Mode")) 34 | bool EnableKeywordMode(TArray wordList); 35 | 36 | UFUNCTION(BlueprintCallable, Category = "Audio", meta = (DisplayName = "Enable Grammar Mode", Keywords = "Speech Recognition Mode")) 37 | bool EnableGrammarMode(FString grammarName); 38 | 39 | // Basic functions 40 | UFUNCTION(BlueprintCallable, Category = "Audio", meta = (DisplayName = "Init", Keywords = "Speech Recognition Init")) 41 | bool Init(ESpeechRecognitionLanguage language); 42 | 43 | UFUNCTION(BlueprintCallable, Category = "Audio", meta = (DisplayName = "SetConfigParam", Keywords = "Speech Recognition Set Config Param")) 44 | bool SetConfigParam(FString param, ESpeechRecognitionParamType type, FString value); 45 | 46 | UFUNCTION(BlueprintCallable, Category = "Audio", meta = (DisplayName = "Shutdown", Keywords = "Speech Recognition Shutdown")) 47 | bool Shutdown(); 48 | 49 | // Callback events 50 | UFUNCTION() 51 | void WordsSpoken_method(FRecognisedPhrases phrases); 52 | 53 | UPROPERTY(BlueprintAssignable, Category = "Audio") 54 | FWordsSpokenSignature OnWordsSpoken; 55 | 56 | UFUNCTION() 57 | void UnknownPhrase_method(); 58 | 59 | UPROPERTY(BlueprintAssignable, Category = "Audio") 60 | FUnknownPhraseSignature OnUnknownPhrase; 61 | 62 | UFUNCTION() 63 | void StartedSpeaking_method(); 64 | 65 | UPROPERTY(BlueprintAssignable, Category = "Audio") 66 | FStartedSpeakingSignature OnStartedSpeaking; 67 | 68 | UFUNCTION() 69 | void StoppedSpeaking_method(); 70 | 71 | UPROPERTY(BlueprintAssignable, Category = "Audio") 72 | FStoppedSpeakingSignature OnStoppedSpeaking; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/Public/SpeechRecognitionWorker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | //General Log 21 | DECLARE_LOG_CATEGORY_EXTERN(SpeechRecognitionPlugin, Log, All); 22 | 23 | #define SENSCR_SHIFT 10 24 | 25 | class ASpeechRecognitionActor; 26 | 27 | using namespace std; 28 | 29 | //Common structures and enumerations 30 | struct FSpeechRecognitionParam 31 | { 32 | char* name; 33 | ESpeechRecognitionParamType type; 34 | char* value; 35 | 36 | // constructor 37 | FSpeechRecognitionParam(char* name, ESpeechRecognitionParamType type, char* value) { 38 | this->name = new char[strlen(name) + 1]; 39 | strcpy(this->name, name); 40 | this->type = type; 41 | this->value = new char[strlen(value) + 1]; 42 | strcpy(this->value, value); 43 | } 44 | }; 45 | 46 | class FSpeechRecognitionWorker :public FRunnable 47 | { 48 | 49 | private: 50 | // Sphinx 51 | ps_decoder_t *ps = NULL; 52 | cmd_ln_t *config = NULL; 53 | ad_rec_t *ad; 54 | int16 adbuf[2048]; 55 | uint8 utt_started, in_speech; 56 | int32 k; 57 | bool initRequired = false; 58 | bool wordsAdded = false; 59 | 60 | //A set of params to apply to Sphinx initialisation 61 | TArray sphinxParams; 62 | 63 | //Speech detection mode 64 | ESpeechRecognitionMode detectionMode; 65 | 66 | //Thread 67 | FRunnableThread* Thread; 68 | 69 | //Pointer to our manager 70 | ASpeechRecognitionActor* Manager; 71 | 72 | //Thread safe counter 73 | FThreadSafeCounter StopTaskCounter; 74 | 75 | //Language 76 | const char* langStr = NULL; 77 | 78 | //Paths 79 | std::string argFilePath; 80 | std::string contentPath_str; 81 | std::string logPath; 82 | std::string modelPath; 83 | std::string languageModel; 84 | std::string dictionaryPath; 85 | 86 | //Stores the recognition keywords, along with their tolerances 87 | std::map keywords; 88 | 89 | //Dictionary 90 | std::map > dictionary; 91 | 92 | //Splits a string by whitespace 93 | std::vector Split(std::string s); 94 | 95 | public: 96 | FSpeechRecognitionWorker(); 97 | virtual ~FSpeechRecognitionWorker(); 98 | 99 | //FRunnable interface 100 | virtual void Stop(); 101 | virtual uint32 Run(); 102 | 103 | //Methods to switch recognition modes 104 | bool EnableKeywordMode(TArray wordList); 105 | bool EnableGrammarMode(FString grammarName); 106 | 107 | //Action methods 108 | void AddWords(TArray dictionaryList); 109 | void InitConfig(); 110 | bool SetConfigParam(FString param, ESpeechRecognitionParamType type, FString value); 111 | void SetLanguage(ESpeechRecognitionLanguage language); 112 | bool StartThread(ASpeechRecognitionActor* manager); 113 | void ShutDown(); 114 | 115 | // Print Debug Text 116 | static void ClientMessage(FString txt); 117 | 118 | }; 119 | 120 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/Source/SpeechRecognition/SpeechRecognition.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | using System.IO; 3 | 4 | namespace UnrealBuildTool.Rules 5 | { 6 | public class SpeechRecognition : ModuleRules 7 | { 8 | 9 | private string ModulePath 10 | { 11 | get { return ModuleDirectory; } 12 | } 13 | 14 | private string ThirdPartyPath 15 | { 16 | get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); } 17 | } 18 | 19 | public SpeechRecognition(TargetInfo Target) 20 | { 21 | PublicIncludePaths.AddRange( 22 | new string[] { 23 | "SpeechRecognition/Public", 24 | // ... add public include paths required here ... 25 | } 26 | ); 27 | 28 | PrivateIncludePaths.AddRange( 29 | new string[] { 30 | "SpeechRecognition/Private", 31 | // ... add other private include paths required here ... 32 | } 33 | ); 34 | 35 | PublicDependencyModuleNames.AddRange( 36 | new string[] 37 | { 38 | "Core", 39 | "CoreUObject", 40 | "Engine", 41 | "InputCore", 42 | "RHI" 43 | // ... add other public dependencies that you statically link with here ... 44 | } 45 | ); 46 | 47 | PrivateDependencyModuleNames.AddRange( 48 | new string[] 49 | { 50 | 51 | } 52 | ); 53 | 54 | DynamicallyLoadedModuleNames.AddRange( 55 | new string[] 56 | { 57 | // ... add any modules that your module loads dynamically here ... 58 | } 59 | ); 60 | 61 | LoadSphinxBase(Target); 62 | LoadPocketSphinx(Target); 63 | } 64 | 65 | 66 | public bool LoadSphinxBase(TargetInfo Target) 67 | { 68 | bool isLibrarySupported = false; 69 | 70 | if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)) 71 | { 72 | isLibrarySupported = true; 73 | 74 | string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86"; 75 | string LibrariesPath = Path.Combine(ThirdPartyPath, "SphinxBase", "Libraries"); 76 | LibrariesPath = Path.Combine(LibrariesPath, PlatformString); 77 | 78 | PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "SphinxBase.lib")); 79 | 80 | // TODO: Copy dlls to alternative package directory, to be loaded through a manual process 81 | PublicDelayLoadDLLs.Add("SphinxBase.dll"); 82 | RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(Path.Combine(LibrariesPath, "SphinxBase.dll")))); 83 | } 84 | 85 | if (Target.Platform == UnrealTargetPlatform.Mac) 86 | { 87 | isLibrarySupported = true; 88 | 89 | string LibraryPath = Path.Combine(ThirdPartyPath, "SphinxBase", "Libraries"); 90 | 91 | LibraryPath = Path.Combine(LibraryPath, "osx"); 92 | 93 | PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "libopenal.dylib")); 94 | PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "libsphinxad.a")); 95 | PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "libsphinxbase.a")); 96 | } 97 | 98 | if (isLibrarySupported) 99 | { 100 | // Include path 101 | PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "SphinxBase", "Includes")); 102 | PrivateIncludePaths.Add(Path.Combine(ThirdPartyPath, "SphinxBase", "Includes")); 103 | } 104 | 105 | Definitions.Add(string.Format("WITH_SPHINX_BASE_BINDING={0}", isLibrarySupported ? 1 : 0)); 106 | 107 | return isLibrarySupported; 108 | } 109 | 110 | public bool LoadPocketSphinx(TargetInfo Target) 111 | { 112 | bool isLibrarySupported = false; 113 | 114 | if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)) 115 | { 116 | isLibrarySupported = true; 117 | 118 | string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86"; 119 | string LibrariesPath = Path.Combine(ThirdPartyPath, "PocketSphinx", "Libraries"); 120 | LibrariesPath = Path.Combine(LibrariesPath, PlatformString); 121 | 122 | PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "PocketSphinx.lib")); 123 | 124 | // TODO: Copy dlls to alternative package directory, to be loaded through a manual process 125 | PublicDelayLoadDLLs.Add("PocketSphinx.dll"); 126 | RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(Path.Combine(LibrariesPath, "PocketSphinx.dll")))); 127 | } 128 | 129 | if (Target.Platform == UnrealTargetPlatform.Mac) 130 | { 131 | isLibrarySupported = true; 132 | 133 | string LibraryPath = Path.Combine(ThirdPartyPath, "PocketSphinx", "Libraries"); 134 | 135 | LibraryPath = Path.Combine(LibraryPath, "osx"); 136 | 137 | PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "libpocketsphinx.a")); 138 | } 139 | 140 | if (isLibrarySupported) 141 | { 142 | // Include path 143 | PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "PocketSphinx", "Includes")); 144 | PrivateIncludePaths.Add(Path.Combine(ThirdPartyPath, "PocketSphinx", "Includes")); 145 | } 146 | 147 | Definitions.Add(string.Format("WITH_POCKET_SPHINX_BINDING={0}", isLibrarySupported ? 1 : 0)); 148 | 149 | return isLibrarySupported; 150 | } 151 | 152 | } 153 | } -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/SpeechRecognition.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion" : 3, 3 | 4 | "FriendlyName" : "Speech Recognition Plugin", 5 | "Version" : 1, 6 | "VersionName" : "1.0", 7 | "CreatedBy" : "Shane Colbert", 8 | "CreatedByURL" : "http://cmusphinx.sourceforge.net", 9 | "EngineVersion" : "4.9.1", 10 | "Description" : "A minimal implementation of the PocketSphinx library. This plugin is used for implementing simple Speech Recognition into your Unreal projects", 11 | "Category" : "Audio", 12 | "EnabledByDefault" : true, 13 | 14 | "Modules" : 15 | [ 16 | { 17 | "Name" : "SpeechRecognition", 18 | "Type" : "Runtime", 19 | "LoadingPhase" : "PreDefault" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/OpenAL/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/OpenAL/libcommon.a -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/OpenAL/libopenal.1.17.2.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/OpenAL/libopenal.1.17.2.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/OpenAL/libopenal.1.dylib: -------------------------------------------------------------------------------- 1 | libopenal.1.17.2.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/OpenAL/libopenal.dylib: -------------------------------------------------------------------------------- 1 | libopenal.1.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Includes/Makefile.am: -------------------------------------------------------------------------------- 1 | pkginclude_HEADERS = \ 2 | cmdln_macro.h \ 3 | ps_lattice.h \ 4 | ps_mllr.h \ 5 | ps_search.h \ 6 | pocketsphinx_export.h \ 7 | pocketsphinx.h 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Includes/pocketsphinx_export.h: -------------------------------------------------------------------------------- 1 | #ifndef __POCKETSPHINX_EXPORT_H__ 2 | #define __POCKETSPHINX_EXPORT_H__ 3 | 4 | /* Win32 DLL gunk */ 5 | #if defined(_WIN32) && defined(SPHINX_DLL) 6 | #if defined(POCKETSPHINX_EXPORTS) /* DLL itself */ 7 | #define POCKETSPHINX_EXPORT __declspec(dllexport) 8 | #else 9 | #define POCKETSPHINX_EXPORT __declspec(dllimport) 10 | #endif 11 | #else /* No DLL things*/ 12 | #define POCKETSPHINX_EXPORT 13 | #endif 14 | 15 | #endif /* __POCKETSPHINX_EXPORT_H__ */ 16 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Includes/ps_mllr.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2008 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | /** 39 | * @file ps_mllr.h Model-space linear transforms for speaker adaptation 40 | */ 41 | 42 | #ifndef __PS_MLLR_H__ 43 | #define __PS_MLLR_H__ 44 | 45 | /* SphinxBase headers. */ 46 | #include 47 | #include 48 | 49 | /* PocketSphinx headers. */ 50 | #include 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | #if 0 56 | } 57 | #endif 58 | 59 | /** 60 | * Feature space linear transform object. 61 | */ 62 | typedef struct ps_mllr_s ps_mllr_t; 63 | 64 | /** 65 | * Read a speaker-adaptive linear transform from a file. 66 | */ 67 | POCKETSPHINX_EXPORT 68 | ps_mllr_t *ps_mllr_read(char const *file); 69 | 70 | /** 71 | * Retain a pointer to a linear transform. 72 | */ 73 | POCKETSPHINX_EXPORT 74 | ps_mllr_t *ps_mllr_retain(ps_mllr_t *mllr); 75 | 76 | /** 77 | * Release a pointer to a linear transform. 78 | */ 79 | POCKETSPHINX_EXPORT 80 | int ps_mllr_free(ps_mllr_t *mllr); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __PS_MLLR_H__ */ 87 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/osx/libpocketsphinx.3.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/osx/libpocketsphinx.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/osx/libpocketsphinx.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/osx/libpocketsphinx.a -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/osx/libpocketsphinx.dylib: -------------------------------------------------------------------------------- 1 | libpocketsphinx.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x64/pocketsphinx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x64/pocketsphinx.dll -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x64/pocketsphinx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x64/pocketsphinx.lib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x86/pocketsphinx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x86/pocketsphinx.dll -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x86/pocketsphinx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/PocketSphinx/Libraries/x86/pocketsphinx.lib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = sphinxbase 2 | 3 | pkginclude_HEADERS = \ 4 | sphinx_config.h 5 | 6 | EXTRA_DIST = \ 7 | wince/sphinx_config.h \ 8 | wince/config.h \ 9 | win32/sphinx_config.h \ 10 | win32/config.h \ 11 | android/config.h \ 12 | android/sphinx_config.h 13 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/android/config.h: -------------------------------------------------------------------------------- 1 | /* include/config.h. Generated from config.h.in by configure. */ 2 | /* include/config.h.in. Generated from configure.in by autoheader. */ 3 | 4 | /* Default radix point for fixed-point */ 5 | /* #undef DEFAULT_RADIX */ 6 | 7 | /* Enable thread safety */ 8 | #define ENABLE_THREADS /**/ 9 | 10 | /* Use Q15 fixed-point computation */ 11 | /* #undef FIXED16 */ 12 | 13 | /* Use fixed-point computation */ 14 | /* #undef FIXED_POINT */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_DLFCN_H 1 18 | 19 | /* Define if you have the iconv() function. */ 20 | /* #define HAVE_ICONV 1 */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_INTTYPES_H 1 24 | 25 | /* Define to 1 if you have the `asound' library (-lasound). */ 26 | /* #define HAVE_LIBASOUND 1 */ 27 | 28 | /* Define to 1 if you have the `blas' library (-lblas). */ 29 | /* #define HAVE_LIBBLAS 1 */ 30 | 31 | /* Define to 1 if you have the `lapack' library (-llapack). */ 32 | /* #define HAVE_LIBLAPACK 1 */ 33 | 34 | /* Define to 1 if you have the `m' library (-lm). */ 35 | #define HAVE_LIBM 1 36 | 37 | /* Define to 1 if you have the `pthread' library (-lpthread). */ 38 | #define HAVE_LIBPTHREAD 1 39 | 40 | /* Define to 1 if the system has the type `long long'. */ 41 | #define HAVE_LONG_LONG 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_MEMORY_H 1 45 | 46 | /* Define to 1 if you have the `perror' function. */ 47 | #define HAVE_PERROR 1 48 | 49 | /* Define to 1 if you have the `popen' function. */ 50 | #define HAVE_POPEN 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_PTHREAD_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_SNDFILE_H 1 57 | 58 | /* Define to 1 if you have the `snprintf' function. */ 59 | #define HAVE_SNPRINTF 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_STDINT_H 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #define HAVE_STDLIB_H 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_STRINGS_H 1 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_STRING_H 1 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_SYS_STAT_H 1 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #define HAVE_SYS_TYPES_H 1 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_UNISTD_H 1 81 | 82 | /* Define as const if the declaration of iconv() needs const. */ 83 | #define ICONV_CONST 84 | 85 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 86 | */ 87 | #define LT_OBJDIR ".libs/" 88 | 89 | /* Define as the return type of signal handlers (`int' or `void'). */ 90 | #define RETSIGTYPE void 91 | 92 | /* The size of `long', as computed by sizeof. */ 93 | #define SIZEOF_LONG 8 94 | 95 | /* The size of `long long', as computed by sizeof. */ 96 | #define SIZEOF_LONG_LONG 8 97 | 98 | /* Enable debugging output */ 99 | /* #undef SPHINX_DEBUG */ 100 | 101 | /* Define to 1 if you have the ANSI C header files. */ 102 | #define STDC_HEADERS 1 103 | 104 | /* Enable matrix algebra with LAPACK */ 105 | /* #define WITH_LAPACK */ 106 | 107 | /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 108 | significant byte first (like Motorola and SPARC, unlike Intel). */ 109 | #if defined AC_APPLE_UNIVERSAL_BUILD 110 | # if defined __BIG_ENDIAN__ 111 | # define WORDS_BIGENDIAN 1 112 | # endif 113 | #else 114 | # ifndef WORDS_BIGENDIAN 115 | /* # undef WORDS_BIGENDIAN */ 116 | # endif 117 | #endif 118 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/android/sphinx_config.h: -------------------------------------------------------------------------------- 1 | /* include/sphinx_config.h. Generated from sphinx_config.h.in by configure. */ 2 | /* sphinx_config.h: Externally visible configuration parameters */ 3 | 4 | /* Default radix point for fixed-point */ 5 | /* #undef DEFAULT_RADIX */ 6 | 7 | /* Use Q15 fixed-point computation */ 8 | /* #undef FIXED16 */ 9 | 10 | /* Use fixed-point computation */ 11 | /* #undef FIXED_POINT */ 12 | 13 | /* The size of `long', as computed by sizeof. */ 14 | #define SIZEOF_LONG 8 15 | 16 | /* Define to 1 if the system has the type `long long'. */ 17 | #define HAVE_LONG_LONG 1 18 | 19 | /* The size of `long long', as computed by sizeof. */ 20 | #define SIZEOF_LONG_LONG 8 21 | 22 | /* Enable debugging output */ 23 | /* #undef SPHINX_DEBUG */ 24 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinx_config.h.in: -------------------------------------------------------------------------------- 1 | /* sphinx_config.h: Externally visible configuration parameters */ 2 | 3 | /* Default radix point for fixed-point */ 4 | #undef DEFAULT_RADIX 5 | 6 | /* Use Q15 fixed-point computation */ 7 | #undef FIXED16 8 | 9 | /* Use fixed-point computation */ 10 | #undef FIXED_POINT 11 | 12 | /* The size of `long', as computed by sizeof. */ 13 | #undef SIZEOF_LONG 14 | 15 | /* Define to 1 if the system has the type `long long'. */ 16 | #undef HAVE_LONG_LONG 17 | 18 | /* The size of `long long', as computed by sizeof. */ 19 | #undef SIZEOF_LONG_LONG 20 | 21 | /* Enable debugging output */ 22 | #undef SPHINX_DEBUG 23 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/Makefile.am: -------------------------------------------------------------------------------- 1 | pkginclude_HEADERS = \ 2 | ad.h \ 3 | agc.h \ 4 | bio.h \ 5 | bitvec.h \ 6 | byteorder.h \ 7 | case.h \ 8 | ckd_alloc.h \ 9 | clapack_lite.h \ 10 | cmd_ln.h \ 11 | cmn.h \ 12 | err.h \ 13 | f2c.h \ 14 | feat.h \ 15 | fe.h \ 16 | filename.h \ 17 | fixpoint.h \ 18 | fsg_model.h \ 19 | genrand.h \ 20 | glist.h \ 21 | hash_table.h \ 22 | heap.h \ 23 | huff_code.h \ 24 | jsgf.h \ 25 | listelem_alloc.h \ 26 | logmath.h \ 27 | matrix.h \ 28 | mmio.h \ 29 | mulaw.h \ 30 | ngram_model.h \ 31 | pio.h \ 32 | yin.h \ 33 | prim_type.h \ 34 | profile.h \ 35 | sbthread.h \ 36 | sphinxbase_export.h \ 37 | strfuncs.h 38 | 39 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/ad.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2014 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /** \file ad.h 38 | * \brief generic live audio interface for recording and playback 39 | */ 40 | 41 | #ifndef _AD_H_ 42 | #define _AD_H_ 43 | 44 | #include 45 | 46 | #include 47 | #include 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | #if 0 53 | /* Fool Emacs. */ 54 | } 55 | #endif 56 | 57 | #define DEFAULT_SAMPLES_PER_SEC 16000 58 | 59 | /* Return codes */ 60 | #define AD_OK 0 61 | #define AD_EOF -1 62 | #define AD_ERR_GEN -1 63 | #define AD_ERR_NOT_OPEN -2 64 | #define AD_ERR_WAVE -3 65 | 66 | typedef struct ad_rec_s ad_rec_t; 67 | 68 | /** 69 | * Open a specific audio device for recording. 70 | * 71 | * The device is opened in non-blocking mode and placed in idle state. 72 | * 73 | * @return pointer to read-only ad_rec_t structure if successful, NULL 74 | * otherwise. The return value to be used as the first argument to 75 | * other recording functions. 76 | */ 77 | SPHINXBASE_EXPORT 78 | ad_rec_t *ad_open_dev ( 79 | const char *dev, /**< Device name (platform-specific) */ 80 | int32 samples_per_sec /**< Samples per second */ 81 | ); 82 | 83 | /** 84 | * Open the default audio device with a given sampling rate. 85 | */ 86 | SPHINXBASE_EXPORT 87 | ad_rec_t *ad_open_sps ( 88 | int32 samples_per_sec /**< Samples per second */ 89 | ); 90 | 91 | 92 | /** 93 | * Open the default audio device. 94 | */ 95 | SPHINXBASE_EXPORT 96 | ad_rec_t *ad_open ( void ); 97 | 98 | 99 | /* Start audio recording. Return value: 0 if successful, <0 otherwise */ 100 | SPHINXBASE_EXPORT 101 | int32 ad_start_rec (ad_rec_t *); 102 | 103 | 104 | /* Stop audio recording. Return value: 0 if successful, <0 otherwise */ 105 | SPHINXBASE_EXPORT 106 | int32 ad_stop_rec (ad_rec_t *); 107 | 108 | 109 | /* Close the recording device. Return value: 0 if successful, <0 otherwise */ 110 | SPHINXBASE_EXPORT 111 | int32 ad_close (ad_rec_t *); 112 | 113 | /* 114 | * Read next block of audio samples while recording; read upto max samples into buf. 115 | * Return value: # samples actually read (could be 0 since non-blocking); -1 if not 116 | * recording and no more samples remaining to be read from most recent recording. 117 | */ 118 | SPHINXBASE_EXPORT 119 | int32 ad_read (ad_rec_t *, int16 *buf, int32 max); 120 | 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/agc.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * agc.h -- Various forms of automatic gain control (AGC) 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log$ 49 | * Revision 1.1 2006/04/05 20:27:30 dhdfu 50 | * A Great Reorganzation of header files and executables 51 | * 52 | * Revision 1.8 2005/06/21 19:25:41 arthchan2003 53 | * 1, Fixed doxygen documentation. 2, Added $ keyword. 54 | * 55 | * Revision 1.4 2005/06/13 04:02:56 archan 56 | * Fixed most doxygen-style documentation under libs3decoder. 57 | * 58 | * Revision 1.3 2005/03/30 01:22:46 archan 59 | * Fixed mistakes in last updates. Add 60 | * 61 | * 62 | * 28-Apr-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 63 | * Copied from previous version. 64 | */ 65 | 66 | 67 | #ifndef _S3_AGC_H_ 68 | #define _S3_AGC_H_ 69 | 70 | /* Win32/WinCE DLL gunk */ 71 | #include 72 | 73 | #include 74 | #include 75 | 76 | /** \file agc.h 77 | * \brief routine that implements automatic gain control 78 | * 79 | * \warning This function may not be fully compatible with 80 | * SphinxTrain's family of AGC. 81 | * 82 | * This implements AGC. 83 | */ 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | #if 0 88 | /* Fool Emacs. */ 89 | } 90 | #endif 91 | 92 | /** 93 | * Types of acoustic gain control to apply to the features. 94 | */ 95 | typedef enum agc_type_e { 96 | AGC_NONE = 0, 97 | AGC_MAX, 98 | AGC_EMAX, 99 | AGC_NOISE 100 | } agc_type_t; 101 | 102 | /** Convert string representation (from command-line) to agc_type_t */ 103 | SPHINXBASE_EXPORT 104 | agc_type_t agc_type_from_str(const char *str); 105 | 106 | /** String representations of agc_type_t values. */ 107 | SPHINXBASE_EXPORT 108 | extern const char *agc_type_str[]; 109 | 110 | /** 111 | * Structure holding data for doing AGC. 112 | **/ 113 | typedef struct agc_s { 114 | mfcc_t max; /**< Estimated max for current utterance (for AGC_EMAX) */ 115 | mfcc_t obs_max; /**< Observed max in current utterance */ 116 | int32 obs_frame; /**< Whether any data was observed after prev update */ 117 | int32 obs_utt; /**< Whether any utterances have been observed */ 118 | mfcc_t obs_max_sum; 119 | mfcc_t noise_thresh; /**< Noise threshold (for AGC_NOISE only) */ 120 | } agc_t; 121 | 122 | /** 123 | * Initialize AGC structure with default values. 124 | */ 125 | SPHINXBASE_EXPORT 126 | agc_t *agc_init(void); 127 | 128 | /** 129 | * Free AGC structure. 130 | */ 131 | SPHINXBASE_EXPORT 132 | void agc_free(agc_t *agc); 133 | 134 | /** 135 | * Apply AGC to the given mfc vectors (normalize all C0 mfc coefficients in the given 136 | * input such that the max C0 value is 0, by subtracting the input max C0 from all). 137 | * This function operates on an entire utterance at a time. Hence, the entire utterance 138 | * must be available beforehand (batchmode). 139 | */ 140 | SPHINXBASE_EXPORT 141 | void agc_max(agc_t *agc, /**< In: AGC structure (not used) */ 142 | mfcc_t **mfc, /**< In/Out: mfc[f] = cepstrum vector in frame f */ 143 | int32 n_frame /**< In: number of frames of cepstrum vectors supplied */ 144 | ); 145 | 146 | /** 147 | * Apply AGC to the given block of MFC vectors. 148 | * Unlike agc_max() this does not require the entire utterance to be 149 | * available. Call agc_emax_update() at the end of each utterance to 150 | * update the AGC parameters. */ 151 | SPHINXBASE_EXPORT 152 | void agc_emax(agc_t *agc, /**< In: AGC structure */ 153 | mfcc_t **mfc, /**< In/Out: mfc[f] = cepstrum vector in frame f */ 154 | int32 n_frame /**< In: number of frames of cepstrum vectors supplied */ 155 | ); 156 | 157 | /** 158 | * Update AGC parameters for next utterance. 159 | **/ 160 | SPHINXBASE_EXPORT 161 | void agc_emax_update(agc_t *agc /**< In: AGC structure */ 162 | ); 163 | 164 | /** 165 | * Get the current AGC maximum estimate. 166 | **/ 167 | SPHINXBASE_EXPORT 168 | float32 agc_emax_get(agc_t *agc); 169 | 170 | /** 171 | * Set the current AGC maximum estimate. 172 | **/ 173 | SPHINXBASE_EXPORT 174 | void agc_emax_set(agc_t *agc, float32 m); 175 | 176 | /** 177 | * Apply AGC using noise threshold to the given block of MFC vectors. 178 | **/ 179 | SPHINXBASE_EXPORT 180 | void agc_noise(agc_t *agc, /**< In: AGC structure */ 181 | mfcc_t **mfc, /**< In/Out: mfc[f] = cepstrum vector in frame f */ 182 | int32 n_frame /**< In: number of frames of cepstrum vectors supplied */ 183 | ); 184 | 185 | /** 186 | * Get the current AGC noise threshold. 187 | **/ 188 | SPHINXBASE_EXPORT 189 | float32 agc_get_threshold(agc_t *agc); 190 | 191 | /** 192 | * Set the current AGC noise threshold. 193 | **/ 194 | SPHINXBASE_EXPORT 195 | void agc_set_threshold(agc_t *agc, float32 threshold); 196 | 197 | 198 | #ifdef __cplusplus 199 | } 200 | #endif 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/bitvec.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | #ifndef _LIBUTIL_BITVEC_H_ 39 | #define _LIBUTIL_BITVEC_H_ 40 | 41 | #include 42 | 43 | /* Win32/WinCE DLL gunk */ 44 | #include 45 | 46 | #include 47 | #include 48 | 49 | /** 50 | * @file bitvec.h 51 | * @brief An implementation of bit vectors. 52 | * 53 | * Implementation of basic operations of bit vectors. 54 | */ 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | #if 0 60 | /* Fool Emacs. */ 61 | } 62 | #endif 63 | 64 | #define BITVEC_BITS 32 65 | typedef uint32 bitvec_t; 66 | 67 | /** 68 | * Number of bitvec_t in a bit vector 69 | */ 70 | #define bitvec_size(n) (((n)+BITVEC_BITS-1)/BITVEC_BITS) 71 | 72 | /** 73 | * Allocate a bit vector, all bits are clear 74 | */ 75 | #define bitvec_alloc(n) ckd_calloc(bitvec_size(n), sizeof(bitvec_t)) 76 | 77 | /** 78 | * Resize a bit vector, clear the remaining bits 79 | */ 80 | SPHINXBASE_EXPORT 81 | bitvec_t *bitvec_realloc(bitvec_t *vec, /* In: Bit vector to search */ 82 | size_t old_len, /* In: Old length */ 83 | size_t new_len); /* In: New lenght of above bit vector */ 84 | /** 85 | * Free a bit vector. 86 | */ 87 | #define bitvec_free(v) ckd_free(v) 88 | 89 | /** 90 | * Set the b-th bit of bit vector v 91 | * @param v is a vector 92 | * @param b is the bit which will be set 93 | */ 94 | 95 | #define bitvec_set(v,b) (v[(b)/BITVEC_BITS] |= (1UL << ((b) & (BITVEC_BITS-1)))) 96 | 97 | /** 98 | * Set all n bits in bit vector v 99 | * @param v is a vector 100 | * @param n is the number of bits 101 | */ 102 | 103 | #define bitvec_set_all(v,n) memset(v, (bitvec_t)-1, \ 104 | (((n)+BITVEC_BITS-1)/BITVEC_BITS) * \ 105 | sizeof(bitvec_t)) 106 | /** 107 | * Clear the b-th bit of bit vector v 108 | * @param v is a vector 109 | * @param b is the bit which will be set 110 | */ 111 | 112 | #define bitvec_clear(v,b) (v[(b)/BITVEC_BITS] &= ~(1UL << ((b) & (BITVEC_BITS-1)))) 113 | 114 | /** 115 | * Clear all n bits in bit vector v 116 | * @param v is a vector 117 | * @param n is the number of bits 118 | */ 119 | 120 | #define bitvec_clear_all(v,n) memset(v, 0, (((n)+BITVEC_BITS-1)/BITVEC_BITS) * \ 121 | sizeof(bitvec_t)) 122 | 123 | /** 124 | * Check whether the b-th bit is set in vector v 125 | * @param v is a vector 126 | * @param b is the bit which will be checked 127 | */ 128 | 129 | #define bitvec_is_set(v,b) (v[(b)/BITVEC_BITS] & (1UL << ((b) & (BITVEC_BITS-1)))) 130 | 131 | /** 132 | * Check whether the b-th bit is cleared in vector v 133 | * @param v is a vector 134 | * @param b is the bit which will be checked 135 | */ 136 | 137 | #define bitvec_is_clear(v,b) (! (bitvec_is_set(v,b))) 138 | 139 | 140 | /** 141 | * Return the number of bits set in the given bitvector. 142 | * 143 | * @param vec is the bit vector 144 | * @param len is the length of bit vector vec 145 | * @return the number of bits being set in vector vec 146 | */ 147 | SPHINXBASE_EXPORT 148 | size_t bitvec_count_set(bitvec_t *vec, /* In: Bit vector to search */ 149 | size_t len); /* In: Lenght of above bit vector */ 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/byteorder.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2001 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | /* 39 | * byteorder.h -- Byte swapping ordering macros. 40 | * 41 | * ********************************************** 42 | * CMU ARPA Speech Project 43 | * 44 | * Copyright (c) 1996 Carnegie Mellon University. 45 | * ALL RIGHTS RESERVED. 46 | * ********************************************** 47 | * 48 | * HISTORY 49 | * 50 | * $Log: byteorder.h,v $ 51 | * Revision 1.8 2005/09/01 21:09:54 dhdfu 52 | * Really, actually, truly consolidate byteswapping operations into 53 | * byteorder.h. Where unconditional byteswapping is needed, SWAP_INT32() 54 | * and SWAP_INT16() are to be used. The WORDS_BIGENDIAN macro from 55 | * autoconf controls the functioning of the conditional swap macros 56 | * (SWAP_?[LW]) whose names and semantics have been regularized. 57 | * Private, adhoc macros have been removed. 58 | * 59 | */ 60 | 61 | #ifndef __S2_BYTEORDER_H__ 62 | #define __S2_BYTEORDER_H__ 1 63 | 64 | /* Macro to byteswap an int16 variable. x = ptr to variable */ 65 | #define SWAP_INT16(x) *(x) = ((0x00ff & (*(x))>>8) | (0xff00 & (*(x))<<8)) 66 | 67 | /* Macro to byteswap an int32 variable. x = ptr to variable */ 68 | #define SWAP_INT32(x) *(x) = ((0x000000ff & (*(x))>>24) | \ 69 | (0x0000ff00 & (*(x))>>8) | \ 70 | (0x00ff0000 & (*(x))<<8) | \ 71 | (0xff000000 & (*(x))<<24)) 72 | 73 | /* Macro to byteswap a float32 variable. x = ptr to variable */ 74 | #define SWAP_FLOAT32(x) SWAP_INT32((int32 *) x) 75 | 76 | /* Macro to byteswap a float64 variable. x = ptr to variable */ 77 | #define SWAP_FLOAT64(x) { int *low = (int *) (x), *high = (int *) (x) + 1,\ 78 | temp;\ 79 | SWAP_INT32(low); SWAP_INT32(high);\ 80 | temp = *low; *low = *high; *high = temp;} 81 | 82 | #ifdef WORDS_BIGENDIAN 83 | #define SWAP_BE_64(x) 84 | #define SWAP_BE_32(x) 85 | #define SWAP_BE_16(x) 86 | #define SWAP_LE_64(x) SWAP_FLOAT64(x) 87 | #define SWAP_LE_32(x) SWAP_INT32(x) 88 | #define SWAP_LE_16(x) SWAP_INT16(x) 89 | #else 90 | #define SWAP_LE_64(x) 91 | #define SWAP_LE_32(x) 92 | #define SWAP_LE_16(x) 93 | #define SWAP_BE_64(x) SWAP_FLOAT64(x) 94 | #define SWAP_BE_32(x) SWAP_INT32(x) 95 | #define SWAP_BE_16(x) SWAP_INT16(x) 96 | #endif 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/case.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * case.h -- Upper/lower case conversion routines 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: case.h,v $ 49 | * Revision 1.7 2005/06/22 02:58:54 arthchan2003 50 | * Added keyword 51 | * 52 | * Revision 1.3 2005/03/30 01:22:48 archan 53 | * Fixed mistakes in last updates. Add 54 | * 55 | * 56 | * 18-Jun-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 57 | * Added strcmp_nocase, UPPER_CASE and LOWER_CASE definitions. 58 | * 59 | * 16-Feb-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 60 | * Created. 61 | */ 62 | 63 | 64 | /** 65 | * @file case.h 66 | * @brief Locale-independent implementation of case swapping operation. 67 | * 68 | * This function implements ASCII-only case switching and comparison 69 | * related operations, which do not depend on the locale and are 70 | * guaranteed to exist on all versions of Windows. 71 | */ 72 | 73 | #ifndef _LIBUTIL_CASE_H_ 74 | #define _LIBUTIL_CASE_H_ 75 | 76 | #include 77 | 78 | #include 79 | #include 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | #if 0 85 | /* Fool Emacs. */ 86 | } 87 | #endif 88 | 89 | /** 90 | * Return upper case form for c 91 | */ 92 | #define UPPER_CASE(c) ((((c) >= 'a') && ((c) <= 'z')) ? (c-32) : c) 93 | 94 | /** 95 | * Return lower case form for c 96 | */ 97 | #define LOWER_CASE(c) ((((c) >= 'A') && ((c) <= 'Z')) ? (c+32) : c) 98 | 99 | 100 | /** 101 | * Convert str to all upper case. 102 | * @param str is a string. 103 | */ 104 | SPHINXBASE_EXPORT 105 | void ucase(char *str); 106 | 107 | /** 108 | * Convert str to all lower case 109 | * @param str is a string. 110 | */ 111 | SPHINXBASE_EXPORT 112 | void lcase(char *str); 113 | 114 | /** 115 | * (FIXME! The implementation is incorrect!) 116 | * Case insensitive string compare. Return the usual -1, 0, +1, depending on 117 | * str1 <, =, > str2 (case insensitive, of course). 118 | * @param str1 is the first string. 119 | * @param str2 is the second string. 120 | */ 121 | SPHINXBASE_EXPORT 122 | int32 strcmp_nocase(const char *str1, const char *str2); 123 | 124 | /** 125 | * Like strcmp_nocase() but with a maximum length. 126 | */ 127 | SPHINXBASE_EXPORT 128 | int32 strncmp_nocase(const char *str1, const char *str2, size_t len); 129 | 130 | 131 | #ifdef __cplusplus 132 | } 133 | #endif 134 | 135 | #endif 136 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/clapack_lite.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | #ifndef __CLAPACK_LITE_H 3 | #define __CLAPACK_LITE_H 4 | 5 | #include "f2c.h" 6 | 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | #if 0 12 | /* Fool Emacs. */ 13 | } 14 | #endif 15 | 16 | /* Subroutine */ int sgemm_(char *transa, char *transb, integer *m, integer * 17 | n, integer *k, real *alpha, real *a, integer *lda, real *b, integer * 18 | ldb, real *beta, real *c__, integer *ldc); 19 | /* Subroutine */ int sgemv_(char *trans, integer *m, integer *n, real *alpha, 20 | real *a, integer *lda, real *x, integer *incx, real *beta, real *y, 21 | integer *incy); 22 | /* Subroutine */ int ssymm_(char *side, char *uplo, integer *m, integer *n, 23 | real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta, 24 | real *c__, integer *ldc); 25 | 26 | /* Subroutine */ int sposv_(char *uplo, integer *n, integer *nrhs, real *a, 27 | integer *lda, real *b, integer *ldb, integer *info); 28 | /* Subroutine */ int spotrf_(char *uplo, integer *n, real *a, integer *lda, 29 | integer *info); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | 36 | #endif /* __CLAPACK_LITE_H */ 37 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/cmn.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * cmn.h -- Various forms of cepstral mean normalization 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log$ 49 | * Revision 1.1 2006/04/05 20:27:30 dhdfu 50 | * A Great Reorganzation of header files and executables 51 | * 52 | * Revision 1.13 2006/02/23 03:48:27 arthchan2003 53 | * Resolved conflict in cmn.h 54 | * 55 | * 56 | * Revision 1.12 2006/02/22 23:43:55 arthchan2003 57 | * Merged from the branch SPHINX3_5_2_RCI_IRII_BRANCH: Put data structure into the cmn_t structure. 58 | * 59 | * Revision 1.11.4.2 2005/10/17 04:45:57 arthchan2003 60 | * Free stuffs in cmn and feat corectly. 61 | * 62 | * Revision 1.11.4.1 2005/07/05 06:25:08 arthchan2003 63 | * Fixed dox-doc. 64 | * 65 | * Revision 1.11 2005/06/21 19:28:00 arthchan2003 66 | * 1, Fixed doxygen documentation. 2, Added $ keyword. 67 | * 68 | * Revision 1.4 2005/06/13 04:02:56 archan 69 | * Fixed most doxygen-style documentation under libs3decoder. 70 | * 71 | * Revision 1.3 2005/03/30 01:22:46 archan 72 | * Fixed mistakes in last updates. Add 73 | * 74 | * 75 | * 20.Apr.2001 RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu) 76 | * Added cmn_free() and moved *mean and *var out global space and named them cmn_mean and cmn_var 77 | * 78 | * 28-Apr-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 79 | * Copied from previous version. 80 | */ 81 | 82 | 83 | #ifndef _S3_CMN_H_ 84 | #define _S3_CMN_H_ 85 | 86 | /* Win32/WinCE DLL gunk */ 87 | #include 88 | #include 89 | #include 90 | 91 | #ifdef __cplusplus 92 | extern "C" { 93 | #endif 94 | #if 0 95 | /* Fool Emacs. */ 96 | } 97 | #endif 98 | 99 | /** \file cmn.h 100 | * \brief Apply Cepstral Mean Normalization (CMN) to the set of input mfc frames. 101 | * 102 | * By subtractingthe mean of the input from each frame. C0 is also included in this process. 103 | * This function operates on an entire utterance at a time. Hence, the entire utterance 104 | * must be available beforehand (batchmode). 105 | */ 106 | 107 | /** 108 | * Types of cepstral mean normalization to apply to the features. 109 | */ 110 | typedef enum cmn_type_e { 111 | CMN_NONE = 0, 112 | CMN_CURRENT, 113 | CMN_PRIOR 114 | } cmn_type_t; 115 | 116 | /** String representations of cmn_type_t values. */ 117 | SPHINXBASE_EXPORT 118 | extern const char *cmn_type_str[]; 119 | 120 | /** Convert string representation (from command-line) to cmn_type_t */ 121 | SPHINXBASE_EXPORT 122 | cmn_type_t cmn_type_from_str(const char *str); 123 | 124 | /** \struct cmn_t 125 | * \brief wrapper of operation of the cepstral mean normalization. 126 | */ 127 | 128 | typedef struct { 129 | mfcc_t *cmn_mean; /**< Temporary variable: current means */ 130 | mfcc_t *cmn_var; /**< Temporary variables: stored the cmn variance */ 131 | mfcc_t *sum; /**< The sum of the cmn frames */ 132 | int32 nframe; /**< Number of frames */ 133 | int32 veclen; /**< Length of cepstral vector */ 134 | } cmn_t; 135 | 136 | SPHINXBASE_EXPORT 137 | cmn_t* cmn_init(int32 veclen); 138 | 139 | /** 140 | * CMN for the whole sentence 141 | */ 142 | SPHINXBASE_EXPORT 143 | void cmn (cmn_t *cmn, /**< In/Out: cmn normalization, which contains the cmn_mean and cmn_var) */ 144 | mfcc_t **mfc, /**< In/Out: mfc[f] = mfc vector in frame f */ 145 | int32 varnorm,/**< In: if not FALSE, variance normalize the input vectors 146 | to have unit variance (along each dimension independently); 147 | Irrelevant if no cmn is performed */ 148 | int32 n_frame /**< In: Number of frames of mfc vectors */ 149 | ); 150 | 151 | #define CMN_WIN_HWM 800 /* #frames after which window shifted */ 152 | #define CMN_WIN 500 153 | 154 | /** 155 | * CMN for one block of data, using prior mean 156 | */ 157 | SPHINXBASE_EXPORT 158 | void cmn_prior(cmn_t *cmn, /**< In/Out: cmn normalization, which contains 159 | the cmn_mean and cmn_var) */ 160 | mfcc_t **incep, /**< In/Out: mfc[f] = mfc vector in frame f*/ 161 | int32 varnorm, /**< This flag should always be 0 for live */ 162 | int32 nfr /**< Number of incoming frames */ 163 | ); 164 | 165 | /** 166 | * Update prior mean based on observed data 167 | */ 168 | SPHINXBASE_EXPORT 169 | void cmn_prior_update(cmn_t *cmn); 170 | 171 | /** 172 | * Set the prior mean. 173 | */ 174 | SPHINXBASE_EXPORT 175 | void cmn_prior_set(cmn_t *cmn, mfcc_t const *vec); 176 | 177 | /** 178 | * Get the prior mean. 179 | */ 180 | SPHINXBASE_EXPORT 181 | void cmn_prior_get(cmn_t *cmn, mfcc_t *vec); 182 | 183 | /* RAH, free previously allocated memory */ 184 | SPHINXBASE_EXPORT 185 | void cmn_free (cmn_t *cmn); 186 | 187 | #ifdef __cplusplus 188 | } 189 | #endif 190 | 191 | #endif 192 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/err.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | #ifndef _LIBUTIL_ERR_H_ 39 | #define _LIBUTIL_ERR_H_ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | /* Win32/WinCE DLL gunk */ 47 | #include 48 | 49 | /** 50 | * @file err.h 51 | * @brief Implementation of logging routines. 52 | * 53 | * Logging, warning, debug and error message output funtionality is provided in this file. 54 | * Sphinxbase defines several level of logging messages - INFO, WARNING, ERROR, FATAL. By 55 | * default output goes to standard error output. 56 | * 57 | * Logging is implemented through macros. They take same arguments as printf: format string and 58 | * values. By default source file name and source line are prepended to the message. Log output 59 | * could be redirected to any file using err_set_logfp() and err_set_logfile() functions. To disable 60 | * logging in your application, call err_set_logfp(NULL). 61 | * 62 | * It's possible to log multiline info messages, to do that you need to start message with 63 | * E_INFO and output other lines with E_INFOCONT. 64 | */ 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | #if 0 70 | /* Fool Emacs. */ 71 | } 72 | #endif 73 | 74 | #define E_SYSCALL(stmt, ...) if (stmt) E_FATAL_SYSTEM(__VA_ARGS__); 75 | 76 | #define FILELINE __FILE__ , __LINE__ 77 | 78 | /** 79 | * Exit with non-zero status after error message 80 | */ 81 | #define E_FATAL(...) \ 82 | do { \ 83 | err_msg(ERR_FATAL, FILELINE, __VA_ARGS__); \ 84 | exit(EXIT_FAILURE); \ 85 | } while (0) 86 | 87 | /** 88 | * Print error text; Call perror(""); exit(errno); 89 | */ 90 | #define E_FATAL_SYSTEM(...) \ 91 | do { \ 92 | err_msg_system(ERR_FATAL, FILELINE, __VA_ARGS__); \ 93 | exit(EXIT_FAILURE); \ 94 | } while (0) 95 | 96 | /** 97 | * Print error text; Call perror(""); 98 | */ 99 | #define E_ERROR_SYSTEM(...) err_msg_system(ERR_ERROR, FILELINE, __VA_ARGS__) 100 | 101 | /** 102 | * Print error message to error log 103 | */ 104 | #define E_ERROR(...) err_msg(ERR_ERROR, FILELINE, __VA_ARGS__) 105 | 106 | /** 107 | * Print warning message to error log 108 | */ 109 | #define E_WARN(...) err_msg(ERR_WARN, FILELINE, __VA_ARGS__) 110 | 111 | /** 112 | * Print logging information to standard error stream 113 | */ 114 | #define E_INFO(...) err_msg(ERR_INFO, FILELINE, __VA_ARGS__) 115 | 116 | /** 117 | * Continue printing the information to standard error stream 118 | */ 119 | #define E_INFOCONT(...) err_msg(ERR_INFOCONT, NULL, 0, __VA_ARGS__) 120 | 121 | /** 122 | * Print logging information without filename. 123 | */ 124 | #define E_INFO_NOFN(...) err_msg(ERR_INFO, NULL, 0, __VA_ARGS__) 125 | 126 | /** 127 | * Print debugging information to standard error stream. 128 | * 129 | * This will only print a message if: 130 | * 1. Debugging is enabled at compile time 131 | * 2. The debug level is greater than or equal to \a level 132 | * 133 | * Note that for portability reasons the format and arguments must be 134 | * enclosed in an extra set of parentheses. 135 | */ 136 | #ifdef SPHINX_DEBUG 137 | #define E_DEBUG(level, ...) \ 138 | if (err_get_debug_level() >= level) \ 139 | err_msg(ERR_DEBUG, FILELINE, __VA_ARGS__) 140 | #define E_DEBUGCONT(level, ...) \ 141 | if (err_get_debug_level() >= level) \ 142 | err_msg(ERR_DEBUG, NULL, 0, __VA_ARGS__) 143 | #else 144 | #define E_DEBUG(level,x) 145 | #define E_DEBUGCONT(level,x) 146 | #endif 147 | 148 | typedef enum err_e { 149 | ERR_DEBUG, 150 | ERR_INFO, 151 | ERR_INFOCONT, 152 | ERR_WARN, 153 | ERR_ERROR, 154 | ERR_FATAL, 155 | ERR_MAX 156 | } err_lvl_t; 157 | 158 | SPHINXBASE_EXPORT void 159 | err_msg(err_lvl_t lvl, const char *path, long ln, const char *fmt, ...); 160 | 161 | SPHINXBASE_EXPORT void 162 | err_msg_system(err_lvl_t lvl, const char *path, long ln, const char *fmt, ...); 163 | 164 | SPHINXBASE_EXPORT void 165 | err_logfp_cb(void * user_data, err_lvl_t level, const char *fmt, ...); 166 | 167 | typedef void (*err_cb_f)(void* user_data, err_lvl_t, const char *, ...); 168 | 169 | /** 170 | * Sets function to output error messages. Use it to redirect the logging 171 | * to your application. By default the handler which dumps messages to 172 | * stderr is set. 173 | * 174 | * @param - callback to pass messages too. 175 | */ 176 | SPHINXBASE_EXPORT void 177 | err_set_callback(err_cb_f callback, void *user_data); 178 | 179 | /** 180 | * Direct all logging to a given filehandle if default logfp callback is set. 181 | * 182 | * @param logfp Filehandle to send log messages to, or NULL to disable logging. 183 | */ 184 | SPHINXBASE_EXPORT void 185 | err_set_logfp(FILE *stream); 186 | 187 | /** 188 | * Get the current logging filehandle. 189 | * 190 | * @return Current logging filehandle, NULL if logging is disabled. Initially 191 | * it returns stderr 192 | */ 193 | SPHINXBASE_EXPORT FILE * 194 | err_get_logfp(void); 195 | 196 | /** 197 | * Append all log messages to a given file. 198 | * 199 | * Previous logging filehandle is closed (unless it was stdout or stderr). 200 | * 201 | * @param file File path to send log messages to 202 | * @return 0 for success, <0 for failure (e.g. if file does not exist) 203 | */ 204 | SPHINXBASE_EXPORT int 205 | err_set_logfile(const char *path); 206 | 207 | /** 208 | * Set debugging verbosity level. 209 | * 210 | * Note that debugging messages are only enabled when compiled with -DDEBUG. 211 | * 212 | * @param level Verbosity level to set, or 0 to disable debug messages. 213 | */ 214 | SPHINXBASE_EXPORT 215 | int err_set_debug_level(int level); 216 | 217 | /** 218 | * Get debugging verbosity level. 219 | * 220 | * Note that debugging messages are only enabled when compiled with -DDEBUG. 221 | */ 222 | SPHINXBASE_EXPORT 223 | int err_get_debug_level(void); 224 | 225 | #ifdef __cplusplus 226 | } 227 | #endif 228 | 229 | #endif /* !_ERR_H */ 230 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/f2c.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* f2c.h -- Standard Fortran to C header file */ 3 | 4 | /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." 5 | 6 | - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ 7 | 8 | #ifndef F2C_INCLUDE 9 | #define F2C_INCLUDE 10 | 11 | typedef int integer; 12 | typedef char *address; 13 | typedef short int shortint; 14 | typedef float real; 15 | typedef double doublereal; 16 | typedef struct { real r, i; } complex; 17 | typedef struct { doublereal r, i; } doublecomplex; 18 | typedef int logical; 19 | typedef short int shortlogical; 20 | typedef char logical1; 21 | typedef char integer1; 22 | 23 | #define TRUE_ (1) 24 | #define FALSE_ (0) 25 | 26 | /* Extern is for use with -E */ 27 | #ifndef Extern 28 | #define Extern extern 29 | #endif 30 | 31 | /* I/O stuff */ 32 | 33 | #ifdef f2c_i2 34 | /* for -i2 */ 35 | typedef short flag; 36 | typedef short ftnlen; 37 | typedef short ftnint; 38 | #else 39 | typedef int flag; 40 | typedef int ftnlen; 41 | typedef int ftnint; 42 | #endif 43 | 44 | /*external read, write*/ 45 | typedef struct 46 | { flag cierr; 47 | ftnint ciunit; 48 | flag ciend; 49 | char *cifmt; 50 | ftnint cirec; 51 | } cilist; 52 | 53 | /*internal read, write*/ 54 | typedef struct 55 | { flag icierr; 56 | char *iciunit; 57 | flag iciend; 58 | char *icifmt; 59 | ftnint icirlen; 60 | ftnint icirnum; 61 | } icilist; 62 | 63 | /*open*/ 64 | typedef struct 65 | { flag oerr; 66 | ftnint ounit; 67 | char *ofnm; 68 | ftnlen ofnmlen; 69 | char *osta; 70 | char *oacc; 71 | char *ofm; 72 | ftnint orl; 73 | char *oblnk; 74 | } olist; 75 | 76 | /*close*/ 77 | typedef struct 78 | { flag cerr; 79 | ftnint cunit; 80 | char *csta; 81 | } cllist; 82 | 83 | /*rewind, backspace, endfile*/ 84 | typedef struct 85 | { flag aerr; 86 | ftnint aunit; 87 | } alist; 88 | 89 | /* inquire */ 90 | typedef struct 91 | { flag inerr; 92 | ftnint inunit; 93 | char *infile; 94 | ftnlen infilen; 95 | ftnint *inex; /*parameters in standard's order*/ 96 | ftnint *inopen; 97 | ftnint *innum; 98 | ftnint *innamed; 99 | char *inname; 100 | ftnlen innamlen; 101 | char *inacc; 102 | ftnlen inacclen; 103 | char *inseq; 104 | ftnlen inseqlen; 105 | char *indir; 106 | ftnlen indirlen; 107 | char *infmt; 108 | ftnlen infmtlen; 109 | char *inform; 110 | ftnint informlen; 111 | char *inunf; 112 | ftnlen inunflen; 113 | ftnint *inrecl; 114 | ftnint *innrec; 115 | char *inblank; 116 | ftnlen inblanklen; 117 | } inlist; 118 | 119 | #define VOID void 120 | 121 | union Multitype { /* for multiple entry points */ 122 | shortint h; 123 | integer i; 124 | real r; 125 | doublereal d; 126 | complex c; 127 | doublecomplex z; 128 | }; 129 | 130 | typedef union Multitype Multitype; 131 | 132 | typedef long Long; /* No longer used; formerly in Namelist */ 133 | 134 | struct Vardesc { /* for Namelist */ 135 | char *name; 136 | char *addr; 137 | ftnlen *dims; 138 | int type; 139 | }; 140 | typedef struct Vardesc Vardesc; 141 | 142 | struct Namelist { 143 | char *name; 144 | Vardesc **vars; 145 | int nvars; 146 | }; 147 | typedef struct Namelist Namelist; 148 | 149 | #ifndef abs 150 | #define abs(x) ((x) >= 0 ? (x) : -(x)) 151 | #endif 152 | #define dabs(x) (doublereal)abs(x) 153 | #ifndef min 154 | #define min(a,b) ((a) <= (b) ? (a) : (b)) 155 | #endif 156 | #ifndef max 157 | #define max(a,b) ((a) >= (b) ? (a) : (b)) 158 | #endif 159 | #define dmin(a,b) (doublereal)min(a,b) 160 | #define dmax(a,b) (doublereal)max(a,b) 161 | 162 | /* procedure parameter types for -A and -C++ */ 163 | 164 | #define F2C_proc_par_types 1 165 | #ifdef __cplusplus 166 | typedef int /* Unknown procedure type */ (*U_fp)(...); 167 | typedef shortint (*J_fp)(...); 168 | typedef integer (*I_fp)(...); 169 | typedef real (*R_fp)(...); 170 | typedef doublereal (*D_fp)(...), (*E_fp)(...); 171 | typedef /* Complex */ VOID (*C_fp)(...); 172 | typedef /* Double Complex */ VOID (*Z_fp)(...); 173 | typedef logical (*L_fp)(...); 174 | typedef shortlogical (*K_fp)(...); 175 | typedef /* Character */ VOID (*H_fp)(...); 176 | typedef /* Subroutine */ int (*S_fp)(...); 177 | #else 178 | typedef int /* Unknown procedure type */ (*U_fp)(void); 179 | typedef shortint (*J_fp)(void); 180 | typedef integer (*I_fp)(void); 181 | typedef real (*R_fp)(void); 182 | typedef doublereal (*D_fp)(void), (*E_fp)(void); 183 | typedef /* Complex */ VOID (*C_fp)(void); 184 | typedef /* Double Complex */ VOID (*Z_fp)(void); 185 | typedef logical (*L_fp)(void); 186 | typedef shortlogical (*K_fp)(void); 187 | typedef /* Character */ VOID (*H_fp)(void); 188 | typedef /* Subroutine */ int (*S_fp)(void); 189 | #endif 190 | /* E_fp is for real functions when -R is not specified */ 191 | typedef VOID C_f; /* complex function */ 192 | typedef VOID H_f; /* character function */ 193 | typedef VOID Z_f; /* double complex function */ 194 | typedef doublereal E_f; /* real function with -R not specified */ 195 | 196 | /* undef any lower-case symbols that your C compiler predefines, e.g.: */ 197 | 198 | #ifndef Skip_f2c_Undefs 199 | #undef cray 200 | #undef gcos 201 | #undef mc68010 202 | #undef mc68020 203 | #undef mips 204 | #undef pdp11 205 | #undef sgi 206 | #undef sparc 207 | #undef sun 208 | #undef sun2 209 | #undef sun3 210 | #undef sun4 211 | #undef u370 212 | #undef u3b 213 | #undef u3b2 214 | #undef u3b5 215 | #undef unix 216 | #undef vax 217 | #endif 218 | #endif 219 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/filename.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * filename.h -- File and path name operations. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: filename.h,v $ 49 | * Revision 1.7 2005/06/22 03:01:07 arthchan2003 50 | * Added keyword 51 | * 52 | * Revision 1.3 2005/03/30 01:22:48 archan 53 | * Fixed mistakes in last updates. Add 54 | * 55 | * 56 | * 30-Oct-1997 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University. 57 | * Started. 58 | */ 59 | 60 | 61 | #ifndef _LIBUTIL_FILENAME_H_ 62 | #define _LIBUTIL_FILENAME_H_ 63 | 64 | /* Win32/WinCE DLL gunk */ 65 | #include 66 | #include 67 | 68 | /**\file filename.h 69 | *\brief File names related operation 70 | */ 71 | #ifdef __cplusplus 72 | extern "C" { 73 | #endif 74 | #if 0 75 | /* Fool Emacs. */ 76 | } 77 | #endif 78 | 79 | /** 80 | * Returns the last part of the path, without modifying anything in memory. 81 | */ 82 | SPHINXBASE_EXPORT 83 | const char *path2basename(const char *path); 84 | 85 | /** 86 | * Strip off filename from the given path and copy the directory name into dir 87 | * Caller must have allocated dir (hint: it's always shorter than path). 88 | */ 89 | SPHINXBASE_EXPORT 90 | void path2dirname(const char *path, char *dir); 91 | 92 | 93 | /** 94 | * Strip off the smallest trailing file-extension suffix and copy 95 | * the rest into the given root argument. Caller must have 96 | * allocated root. 97 | */ 98 | SPHINXBASE_EXPORT 99 | void strip_fileext(const char *file, char *root); 100 | 101 | /** 102 | * Test whether a pathname is absolute for the current OS. 103 | */ 104 | SPHINXBASE_EXPORT 105 | int path_is_absolute(const char *file); 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/fixpoint.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2005 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== */ 35 | 36 | /* Fixed-point arithmetic macros. 37 | * 38 | * Author: David Huggins-Daines 39 | */ 40 | 41 | #ifndef _FIXPOINT_H_ 42 | #define _FIXPOINT_H_ 43 | 44 | #include 45 | 46 | /* Win32/WinCE DLL gunk */ 47 | #include 48 | #include 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | #if 0 54 | /* Fool Emacs. */ 55 | } 56 | #endif 57 | 58 | #ifndef DEFAULT_RADIX 59 | #define DEFAULT_RADIX 12 60 | #endif 61 | 62 | /** Fixed-point computation type. */ 63 | typedef int32 fixed32; 64 | 65 | /** Convert floating point to fixed point. */ 66 | #define FLOAT2FIX_ANY(x,radix) \ 67 | (((x)<0.0) ? \ 68 | ((fixed32)((x)*(float32)(1<<(radix)) - 0.5)) \ 69 | : ((fixed32)((x)*(float32)(1<<(radix)) + 0.5))) 70 | #define FLOAT2FIX(x) FLOAT2FIX_ANY(x,DEFAULT_RADIX) 71 | /** Convert fixed point to floating point. */ 72 | #define FIX2FLOAT_ANY(x,radix) ((float32)(x)/(1<<(radix))) 73 | #define FIX2FLOAT(x) FIX2FLOAT_ANY(x,DEFAULT_RADIX) 74 | 75 | /** 76 | * Multiply two fixed point numbers with an arbitrary radix point. 77 | * 78 | * A veritable multiplicity of implementations exist, starting with 79 | * the fastest ones... 80 | */ 81 | 82 | #if defined(__arm__) && !defined(__thumb__) 83 | /* 84 | * This works on most modern ARMs but *only* in ARM mode (for obvious 85 | * reasons), so don't use it in Thumb mode (but why are you building 86 | * signal processing code in Thumb mode?!) 87 | */ 88 | #define FIXMUL(a,b) FIXMUL_ANY(a,b,DEFAULT_RADIX) 89 | #define FIXMUL_ANY(a,b,r) ({ \ 90 | int cl, ch, _a = a, _b = b; \ 91 | __asm__ ("smull %0, %1, %2, %3\n" \ 92 | "mov %0, %0, lsr %4\n" \ 93 | "orr %0, %0, %1, lsl %5\n" \ 94 | : "=&r" (cl), "=&r" (ch) \ 95 | : "r" (_a), "r" (_b), "i" (r), "i" (32-(r)));\ 96 | cl; }) 97 | 98 | #elif defined(_MSC_VER) || (defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8) 99 | /* Standard systems*/ 100 | #define FIXMUL(a,b) FIXMUL_ANY(a,b,DEFAULT_RADIX) 101 | #define FIXMUL_ANY(a,b,radix) ((fixed32)(((int64)(a)*(b))>>(radix))) 102 | 103 | #else 104 | /* Most general case where 'long long' doesn't exist or is slow. */ 105 | #define FIXMUL(a,b) FIXMUL_ANY(a,b,DEFAULT_RADIX) 106 | #define FIXMUL_ANY(a,b,radix) ({ \ 107 | int32 _ah, _bh; \ 108 | uint32 _al, _bl, _t, c; \ 109 | _ah = ((int32)(a)) >> 16; \ 110 | _bh = ((int32)(b)) >> 16; \ 111 | _al = ((uint32)(a)) & 0xffff; \ 112 | _bl = ((uint32)(b)) & 0xffff; \ 113 | _t = _ah * _bl + _al * _bh; \ 114 | c = (fixed32)(((_al * _bl) >> (radix)) \ 115 | + ((_ah * _bh) << (32 - (radix))) \ 116 | + ((radix) > 16 ? (_t >> (radix - 16)) : (_t << (16 - radix)))); \ 117 | c;}) 118 | #endif 119 | 120 | /* Various fixed-point logarithmic functions that we need. */ 121 | /** Minimum value representable in log format. */ 122 | #define MIN_FIXLOG -2829416 /* log(1e-300) * (1< 119 | 120 | /* Win32/WinCE DLL gunk */ 121 | #include 122 | 123 | /** \file genrand.h 124 | *\brief High performance prortable random generator created by Takuji 125 | *Nishimura and Makoto Matsumoto. 126 | * 127 | * A high performance which applied Mersene twister primes to generate 128 | * random number. If probably seeded, the random generator can achieve 129 | * 19937-bits period. For technical detail. Please take a look at 130 | * (FIXME! Need to search for the web site.) http://www. 131 | */ 132 | #ifdef __cplusplus 133 | extern "C" { 134 | #endif 135 | #if 0 136 | /* Fool Emacs. */ 137 | } 138 | #endif 139 | 140 | /** 141 | * Macros to simplify calling of random generator function. 142 | * 143 | */ 144 | #define s3_rand_seed(s) genrand_seed(s); 145 | #define s3_rand_int31() genrand_int31() 146 | #define s3_rand_real() genrand_real3() 147 | #define s3_rand_res53() genrand_res53() 148 | 149 | /** 150 | *Initialize the seed of the random generator. 151 | */ 152 | SPHINXBASE_EXPORT 153 | void genrand_seed(unsigned long s); 154 | 155 | /** 156 | *generates a random number on [0,0x7fffffff]-interval 157 | */ 158 | SPHINXBASE_EXPORT 159 | long genrand_int31(void); 160 | 161 | /** 162 | *generates a random number on (0,1)-real-interval 163 | */ 164 | SPHINXBASE_EXPORT 165 | double genrand_real3(void); 166 | 167 | /** 168 | *generates a random number on [0,1) with 53-bit resolution 169 | */ 170 | SPHINXBASE_EXPORT 171 | double genrand_res53(void); 172 | 173 | #ifdef __cplusplus 174 | } 175 | #endif 176 | 177 | #endif /*_LIBUTIL_GENRAND_H_*/ 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/glist.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * glist.h -- Module for maintaining a generic, linear linked-list structure. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: glist.h,v $ 49 | * Revision 1.9 2005/06/22 03:02:51 arthchan2003 50 | * 1, Fixed doxygen documentation, 2, add keyword. 51 | * 52 | * Revision 1.4 2005/05/03 04:09:11 archan 53 | * Implemented the heart of word copy search. For every ci-phone, every word end, a tree will be allocated to preserve its pathscore. This is different from 3.5 or below, only the best score for a particular ci-phone, regardless of the word-ends will be preserved at every frame. The graph propagation will not collect unused word tree at this point. srch_WST_propagate_wd_lv2 is also as the most stupid in the century. But well, after all, everything needs a start. I will then really get the results from the search and see how it looks. 54 | * 55 | * Revision 1.3 2005/03/30 01:22:48 archan 56 | * Fixed mistakes in last updates. Add 57 | * 58 | * 59 | * 09-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 60 | * Added glist_chkdup_*(). 61 | * 62 | * 13-Feb-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 63 | * Created from earlier version. 64 | */ 65 | 66 | 67 | /** 68 | * \file glist.h 69 | * \brief Generic linked-lists maintenance. 70 | * 71 | * Only insert at the head of the list. A convenient little 72 | * linked-list package, but a double-edged sword: the user must keep 73 | * track of the data type within the linked list elements. When it 74 | * was first written, there was no selective deletions except to 75 | * destroy the entire list. This is modified in later version. 76 | * 77 | * 78 | * (C++ would be good for this, but that's a double-edged sword as well.) 79 | */ 80 | 81 | 82 | #ifndef _LIBUTIL_GLIST_H_ 83 | #define _LIBUTIL_GLIST_H_ 84 | 85 | #include 86 | /* Win32/WinCE DLL gunk */ 87 | #include 88 | #include 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | #if 0 94 | /* Fool Emacs. */ 95 | } 96 | #endif 97 | 98 | /** A node in a generic list 99 | */ 100 | typedef struct gnode_s { 101 | anytype_t data; /** See prim_type.h */ 102 | struct gnode_s *next; /** Next node in list */ 103 | } gnode_t; 104 | typedef gnode_t *glist_t; /** Head of a list of gnodes */ 105 | 106 | 107 | /** Access macros, for convenience 108 | */ 109 | #define gnode_ptr(g) ((g)->data.ptr) 110 | #define gnode_int32(g) ((g)->data.i) 111 | #define gnode_uint32(g) ((g)->data.ui) 112 | #define gnode_float32(g) ((float32)(g)->data.fl) 113 | #define gnode_float64(g) ((g)->data.fl) 114 | #define gnode_next(g) ((g)->next) 115 | 116 | 117 | /** 118 | * Create and prepend a new list node, with the given user-defined data, at the HEAD 119 | * of the given generic list. Return the new list thus formed. 120 | * g may be NULL to indicate an initially empty list. 121 | */ 122 | SPHINXBASE_EXPORT 123 | glist_t glist_add_ptr (glist_t g, /**< a link list */ 124 | void *ptr /**< a pointer */ 125 | ); 126 | 127 | /** 128 | * Create and prepend a new list node containing an integer. 129 | */ 130 | SPHINXBASE_EXPORT 131 | glist_t glist_add_int32 (glist_t g, /**< a link list */ 132 | int32 val /**< an integer value */ 133 | ); 134 | /** 135 | * Create and prepend a new list node containing an unsigned integer. 136 | */ 137 | SPHINXBASE_EXPORT 138 | glist_t glist_add_uint32 (glist_t g, /**< a link list */ 139 | uint32 val /**< an unsigned integer value */ 140 | ); 141 | /** 142 | * Create and prepend a new list node containing a single-precision float. 143 | */ 144 | SPHINXBASE_EXPORT 145 | glist_t glist_add_float32 (glist_t g, /**< a link list */ 146 | float32 val /**< a float32 vlaue */ 147 | ); 148 | /** 149 | * Create and prepend a new list node containing a double-precision float. 150 | */ 151 | SPHINXBASE_EXPORT 152 | glist_t glist_add_float64 (glist_t g, /**< a link list */ 153 | float64 val /**< a float64 vlaue */ 154 | ); 155 | 156 | 157 | 158 | /** 159 | * Create and insert a new list node, with the given user-defined data, after 160 | * the given generic node gn. gn cannot be NULL. 161 | * Return ptr to the newly created gnode_t. 162 | */ 163 | SPHINXBASE_EXPORT 164 | gnode_t *glist_insert_ptr (gnode_t *gn, /**< a generic node which ptr will be inserted after it*/ 165 | void *ptr /**< pointer inserted */ 166 | ); 167 | /** 168 | * Create and insert a new list node containing an integer. 169 | */ 170 | SPHINXBASE_EXPORT 171 | gnode_t *glist_insert_int32 (gnode_t *gn, /**< a generic node which a value will be inserted after it*/ 172 | int32 val /**< int32 inserted */ 173 | ); 174 | /** 175 | * Create and insert a new list node containing an unsigned integer. 176 | */ 177 | SPHINXBASE_EXPORT 178 | gnode_t *glist_insert_uint32 (gnode_t *gn, /**< a generic node which a value will be inserted after it*/ 179 | uint32 val /**< uint32 inserted */ 180 | ); 181 | /** 182 | * Create and insert a new list node containing a single-precision float. 183 | */ 184 | SPHINXBASE_EXPORT 185 | gnode_t *glist_insert_float32 (gnode_t *gn, /**< a generic node which a value will be inserted after it*/ 186 | float32 val /**< float32 inserted */ 187 | ); 188 | /** 189 | * Create and insert a new list node containing a double-precision float. 190 | */ 191 | SPHINXBASE_EXPORT 192 | gnode_t *glist_insert_float64 (gnode_t *gn, /**< a generic node which a value will be inserted after it*/ 193 | float64 val /**< float64 inserted */ 194 | ); 195 | 196 | /** 197 | * Reverse the order of the given glist. (glist_add() adds to the head; one might 198 | * ultimately want the reverse of that.) 199 | * NOTE: The list is reversed "in place"; i.e., no new memory is allocated. 200 | * @return: The head of the new list. 201 | */ 202 | SPHINXBASE_EXPORT 203 | glist_t glist_reverse (glist_t g /**< input link list */ 204 | ); 205 | 206 | 207 | /** 208 | Count the number of element in a given link list 209 | @return the number of elements in the given glist_t 210 | */ 211 | SPHINXBASE_EXPORT 212 | int32 glist_count (glist_t g /**< input link list */ 213 | ); 214 | 215 | /** 216 | * Free the given generic list; user-defined data contained within is not 217 | * automatically freed. The caller must have done that already. 218 | */ 219 | SPHINXBASE_EXPORT 220 | void glist_free (glist_t g); 221 | 222 | 223 | /** 224 | * Free the given node, gn, of a glist, pred being its predecessor in the list. 225 | * Return ptr to the next node in the list after the freed node. 226 | */ 227 | SPHINXBASE_EXPORT 228 | gnode_t *gnode_free(gnode_t *gn, 229 | gnode_t *pred 230 | ); 231 | 232 | /** 233 | * Return the last node in the given list. 234 | */ 235 | SPHINXBASE_EXPORT 236 | gnode_t *glist_tail (glist_t g); 237 | 238 | #ifdef __cplusplus 239 | } 240 | #endif 241 | 242 | #endif 243 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/heap.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * heap.h -- Generic heap structure for inserting in any and popping in sorted 39 | * order. 40 | * 41 | * ********************************************** 42 | * CMU ARPA Speech Project 43 | * 44 | * Copyright (c) 1999 Carnegie Mellon University. 45 | * ALL RIGHTS RESERVED. 46 | * ********************************************** 47 | * 48 | * HISTORY 49 | * $Log: heap.h,v $ 50 | * Revision 1.7 2005/06/22 03:05:49 arthchan2003 51 | * 1, Fixed doxygen documentation, 2, Add keyword. 52 | * 53 | * Revision 1.4 2005/06/15 04:21:46 archan 54 | * 1, Fixed doxygen-documentation, 2, Add keyword such that changes will be logged into a file. 55 | * 56 | * Revision 1.3 2005/03/30 01:22:48 archan 57 | * Fixed mistakes in last updates. Add 58 | * 59 | * 60 | * 23-Dec-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 61 | * Started. 62 | */ 63 | 64 | 65 | #ifndef _LIBUTIL_HEAP_H_ 66 | #define _LIBUTIL_HEAP_H_ 67 | 68 | #include 69 | 70 | /* Win32/WinCE DLL gunk */ 71 | #include 72 | #include 73 | 74 | /** \file heap.h 75 | * \brief Heap Implementation. 76 | * 77 | * General Comment: Sorted heap structure with three main operations: 78 | * 79 | * 1. Insert a data item (with two attributes: an application supplied pointer and an 80 | * integer value; the heap is maintained in ascending order of the integer value). 81 | * 2. Return the currently topmost item (i.e., item with smallest associated value). 82 | * 3. Return the currently topmost item and pop it off the heap. 83 | */ 84 | 85 | #ifdef __cplusplus 86 | extern "C" { 87 | #endif 88 | #if 0 89 | /* Fool Emacs. */ 90 | } 91 | #endif 92 | 93 | 94 | typedef struct heap_s heap_t; 95 | 96 | 97 | /** 98 | * Allocate a new heap and return handle to it. 99 | */ 100 | SPHINXBASE_EXPORT 101 | heap_t *heap_new(void); 102 | 103 | 104 | /** 105 | * Insert a new item into the given heap. 106 | * Return value: 0 if successful, -1 otherwise. 107 | */ 108 | SPHINXBASE_EXPORT 109 | int heap_insert(heap_t *heap, /**< In: Heap into which item is to be inserted */ 110 | void *data, /**< In: Application-determined data pointer */ 111 | int32 val /**< In: According to item entered in sorted heap */ 112 | ); 113 | /** 114 | * Return the topmost item in the heap. 115 | * Return value: 1 if heap is not empty and the topmost value is returned; 116 | * 0 if heap is empty; -1 if some error occurred. 117 | */ 118 | SPHINXBASE_EXPORT 119 | int heap_top(heap_t *heap, /**< In: Heap whose topmost item is to be returned */ 120 | void **data, /**< Out: Data pointer associated with the topmost item */ 121 | int32 *val /**< Out: Value associated with the topmost item */ 122 | ); 123 | /** 124 | * Like heap_top but also pop the top item off the heap. 125 | */ 126 | SPHINXBASE_EXPORT 127 | int heap_pop(heap_t *heap, void **data, int32 *val); 128 | 129 | /** 130 | * Remove an item from the heap. 131 | */ 132 | SPHINXBASE_EXPORT 133 | int heap_remove(heap_t *heap, void *data); 134 | 135 | /** 136 | * Return the number of items in the heap. 137 | */ 138 | SPHINXBASE_EXPORT 139 | size_t heap_size(heap_t *heap); 140 | 141 | /** 142 | * Destroy the given heap; free the heap nodes. NOTE: Data pointers in the nodes are NOT freed. 143 | * Return value: 0 if successful, -1 otherwise. 144 | */ 145 | 146 | SPHINXBASE_EXPORT 147 | int heap_destroy(heap_t *heap); 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/huff_code.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2009 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | /** 39 | * @file huff_code.h 40 | * @brief Huffman code and bitstream implementation 41 | * 42 | * This interface supports building canonical Huffman codes from 43 | * string and integer values. It also provides support for encoding 44 | * and decoding from strings and files, and for reading and writing 45 | * codebooks from files. 46 | */ 47 | 48 | #ifndef __HUFF_CODE_H__ 49 | #define __HUFF_CODE_H__ 50 | 51 | #include 52 | 53 | #include 54 | #include 55 | #include 56 | 57 | typedef struct huff_code_s huff_code_t; 58 | 59 | /** 60 | * Create a codebook from 32-bit integer data. 61 | */ 62 | SPHINXBASE_EXPORT 63 | huff_code_t *huff_code_build_int(int32 const *values, int32 const *frequencies, int nvals); 64 | 65 | /** 66 | * Create a codebook from string data. 67 | */ 68 | SPHINXBASE_EXPORT 69 | huff_code_t *huff_code_build_str(char * const *values, int32 const *frequencies, int nvals); 70 | 71 | /** 72 | * Read a codebook from a file. 73 | */ 74 | SPHINXBASE_EXPORT 75 | huff_code_t *huff_code_read(FILE *infh); 76 | 77 | /** 78 | * Write a codebook to a file. 79 | */ 80 | SPHINXBASE_EXPORT 81 | int huff_code_write(huff_code_t *hc, FILE *outfh); 82 | 83 | /** 84 | * Print a codebook to a file as text (for debugging) 85 | */ 86 | SPHINXBASE_EXPORT 87 | int huff_code_dump(huff_code_t *hc, FILE *dumpfh); 88 | 89 | /** 90 | * Retain a pointer to a Huffman codec object. 91 | */ 92 | SPHINXBASE_EXPORT 93 | huff_code_t *huff_code_retain(huff_code_t *hc); 94 | 95 | /** 96 | * Release a pointer to a Huffman codec object. 97 | */ 98 | SPHINXBASE_EXPORT 99 | int huff_code_free(huff_code_t *hc); 100 | 101 | /** 102 | * Attach a Huffman codec to a file handle for input/output. 103 | */ 104 | SPHINXBASE_EXPORT 105 | FILE *huff_code_attach(huff_code_t *hc, FILE *fh, char const *mode); 106 | 107 | /** 108 | * Detach a Huffman codec from its file handle. 109 | */ 110 | SPHINXBASE_EXPORT 111 | FILE *huff_code_detach(huff_code_t *hc); 112 | 113 | /** 114 | * Encode an integer, writing it to the file handle, if any. 115 | */ 116 | SPHINXBASE_EXPORT 117 | int huff_code_encode_int(huff_code_t *hc, int32 sym, uint32 *outcw); 118 | 119 | /** 120 | * Encode a string, writing it to the file handle, if any. 121 | */ 122 | SPHINXBASE_EXPORT 123 | int huff_code_encode_str(huff_code_t *hc, char const *sym, uint32 *outcw); 124 | 125 | /** 126 | * Decode an integer, reading it from the file if no data given. 127 | */ 128 | SPHINXBASE_EXPORT 129 | int huff_code_decode_int(huff_code_t *hc, int *outval, 130 | char const **inout_data, 131 | size_t *inout_data_len, 132 | int *inout_offset); 133 | 134 | /** 135 | * Decode a string, reading it from the file if no data given. 136 | */ 137 | SPHINXBASE_EXPORT 138 | char const *huff_code_decode_str(huff_code_t *hc, 139 | char const **inout_data, 140 | size_t *inout_data_len, 141 | int *inout_offset); 142 | 143 | #endif /* __HUFF_CODE_H__ */ 144 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/jsgf.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2007 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | #ifndef __JSGF_H__ 39 | #define __JSGF_H__ 40 | 41 | /** 42 | * @file jsgf.h JSGF grammar compiler 43 | * 44 | * This file defines the data structures for parsing JSGF grammars 45 | * into Sphinx finite-state grammars. 46 | **/ 47 | 48 | #include 49 | 50 | /* Win32/WinCE DLL gunk */ 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | #if 0 60 | /* Fool Emacs. */ 61 | } 62 | #endif 63 | 64 | typedef struct jsgf_s jsgf_t; 65 | typedef struct jsgf_rule_s jsgf_rule_t; 66 | 67 | /** 68 | * Create a new JSGF grammar. 69 | * 70 | * @param parent optional parent grammar for this one (NULL, usually). 71 | * @return new JSGF grammar object, or NULL on failure. 72 | */ 73 | SPHINXBASE_EXPORT 74 | jsgf_t *jsgf_grammar_new(jsgf_t *parent); 75 | 76 | /** 77 | * Parse a JSGF grammar from a file. 78 | * 79 | * @param filename the name of the file to parse. 80 | * @param parent optional parent grammar for this one (NULL, usually). 81 | * @return new JSGF grammar object, or NULL on failure. 82 | */ 83 | SPHINXBASE_EXPORT 84 | jsgf_t *jsgf_parse_file(const char *filename, jsgf_t *parent); 85 | 86 | /** 87 | * Parse a JSGF grammar from a string. 88 | * 89 | * @param 0-terminated string with grammar. 90 | * @param parent optional parent grammar for this one (NULL, usually). 91 | * @return new JSGF grammar object, or NULL on failure. 92 | */ 93 | SPHINXBASE_EXPORT 94 | jsgf_t *jsgf_parse_string(const char *string, jsgf_t *parent); 95 | 96 | /** 97 | * Get the grammar name from the file. 98 | */ 99 | SPHINXBASE_EXPORT 100 | char const *jsgf_grammar_name(jsgf_t *jsgf); 101 | 102 | /** 103 | * Free a JSGF grammar. 104 | */ 105 | SPHINXBASE_EXPORT 106 | void jsgf_grammar_free(jsgf_t *jsgf); 107 | 108 | /** 109 | * Iterator over rules in a grammar. 110 | */ 111 | typedef hash_iter_t jsgf_rule_iter_t; 112 | 113 | /** 114 | * Get an iterator over all rules in a grammar. 115 | */ 116 | SPHINXBASE_EXPORT 117 | jsgf_rule_iter_t *jsgf_rule_iter(jsgf_t *grammar); 118 | 119 | /** 120 | * Advance an iterator to the next rule in the grammar. 121 | */ 122 | #define jsgf_rule_iter_next(itor) hash_table_iter_next(itor) 123 | 124 | /** 125 | * Get the current rule in a rule iterator. 126 | */ 127 | #define jsgf_rule_iter_rule(itor) ((jsgf_rule_t *)(itor)->ent->val) 128 | 129 | /** 130 | * Free a rule iterator (if the end hasn't been reached). 131 | */ 132 | #define jsgf_rule_iter_free(itor) hash_table_iter_free(itor) 133 | 134 | /** 135 | * Get a rule by name from a grammar. Name should not contain brackets. 136 | */ 137 | SPHINXBASE_EXPORT 138 | jsgf_rule_t *jsgf_get_rule(jsgf_t *grammar, const char *name); 139 | 140 | /** 141 | * Returns the first public rule of the grammar 142 | */ 143 | SPHINXBASE_EXPORT 144 | jsgf_rule_t *jsgf_get_public_rule(jsgf_t *grammar); 145 | 146 | /** 147 | * Get the rule name from a rule. 148 | */ 149 | SPHINXBASE_EXPORT 150 | char const *jsgf_rule_name(jsgf_rule_t *rule); 151 | 152 | /** 153 | * Test if a rule is public or not. 154 | */ 155 | SPHINXBASE_EXPORT 156 | int jsgf_rule_public(jsgf_rule_t *rule); 157 | 158 | /** 159 | * Build a Sphinx FSG object from a JSGF rule. 160 | */ 161 | SPHINXBASE_EXPORT 162 | fsg_model_t *jsgf_build_fsg(jsgf_t *grammar, jsgf_rule_t *rule, 163 | logmath_t *lmath, float32 lw); 164 | 165 | /** 166 | * Build a Sphinx FSG object from a JSGF rule. 167 | * 168 | * This differs from jsgf_build_fsg() in that it does not do closure 169 | * on epsilon transitions or any other postprocessing. For the time 170 | * being this is necessary in order to write it to a file - the FSG 171 | * code will be fixed soon. 172 | */ 173 | SPHINXBASE_EXPORT 174 | fsg_model_t *jsgf_build_fsg_raw(jsgf_t *grammar, jsgf_rule_t *rule, 175 | logmath_t *lmath, float32 lw); 176 | 177 | 178 | /** 179 | * Read JSGF from file and return FSG object from it. 180 | * 181 | * This function looks for a first public rule in jsgf and constructs JSGF from it. 182 | */ 183 | SPHINXBASE_EXPORT 184 | fsg_model_t *jsgf_read_file(const char *file, logmath_t * lmath, float32 lw); 185 | 186 | /** 187 | * Read JSGF from string and return FSG object from it. 188 | * 189 | * This function looks for a first public rule in jsgf and constructs JSGF from it. 190 | */ 191 | SPHINXBASE_EXPORT 192 | fsg_model_t *jsgf_read_string(const char *string, logmath_t * lmath, float32 lw); 193 | 194 | 195 | /** 196 | * Convert a JSGF rule to Sphinx FSG text form. 197 | * 198 | * This does a direct conversion without doing transitive closure on 199 | * null transitions and so forth. 200 | */ 201 | SPHINXBASE_EXPORT 202 | int jsgf_write_fsg(jsgf_t *grammar, jsgf_rule_t *rule, FILE *outfh); 203 | 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | 208 | 209 | #endif /* __JSGF_H__ */ 210 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/listelem_alloc.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | 38 | #ifndef __LISTELEM_ALLOC_H__ 39 | #define __LISTELEM_ALLOC_H__ 40 | 41 | /** @file listelem_alloc.h 42 | * @brief Fast memory allocator for uniformly sized objects 43 | * @author M K Ravishankar 44 | */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | #if 0 49 | /* Fool Emacs. */ 50 | } 51 | #endif 52 | 53 | #include 54 | #ifdef S60 55 | #include 56 | #endif 57 | 58 | /* Win32/WinCE DLL gunk */ 59 | #include 60 | #include 61 | 62 | /** 63 | * List element allocator object. 64 | */ 65 | typedef struct listelem_alloc_s listelem_alloc_t; 66 | 67 | /** 68 | * Initialize and return a list element allocator. 69 | */ 70 | SPHINXBASE_EXPORT 71 | listelem_alloc_t * listelem_alloc_init(size_t elemsize); 72 | 73 | /** 74 | * Finalize and release all memory associated with a list element allocator. 75 | */ 76 | SPHINXBASE_EXPORT 77 | void listelem_alloc_free(listelem_alloc_t *le); 78 | 79 | 80 | SPHINXBASE_EXPORT 81 | void *__listelem_malloc__(listelem_alloc_t *le, char *file, int line); 82 | 83 | /** 84 | * Allocate a list element and return pointer to it. 85 | */ 86 | #define listelem_malloc(le) __listelem_malloc__((le),__FILE__,__LINE__) 87 | 88 | SPHINXBASE_EXPORT 89 | void *__listelem_malloc_id__(listelem_alloc_t *le, char *file, int line, 90 | int32 *out_id); 91 | 92 | /** 93 | * Allocate a list element, returning a unique identifier. 94 | */ 95 | #define listelem_malloc_id(le, oid) __listelem_malloc_id__((le),__FILE__,__LINE__,(oid)) 96 | 97 | /** 98 | * Retrieve a list element by its identifier. 99 | */ 100 | SPHINXBASE_EXPORT 101 | void *listelem_get_item(listelem_alloc_t *le, int32 id); 102 | 103 | /** 104 | * Free list element of given size 105 | */ 106 | SPHINXBASE_EXPORT 107 | void __listelem_free__(listelem_alloc_t *le, void *elem, char *file, int line); 108 | 109 | /** 110 | * Macro of __listelem_free__ 111 | */ 112 | #define listelem_free(le,el) __listelem_free__((le),(el),__FILE__,__LINE__) 113 | 114 | /** 115 | Print number of allocation, numer of free operation stats 116 | */ 117 | SPHINXBASE_EXPORT 118 | void listelem_stats(listelem_alloc_t *le); 119 | 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/logmath.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2007 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /** 38 | * @file logmath.h 39 | * @brief Fast integer logarithmic addition operations. 40 | * 41 | * In evaluating HMM models, probability values are often kept in log 42 | * domain, to avoid overflow. To enable these logprob values to be 43 | * held in int32 variables without significant loss of precision, a 44 | * logbase of (1+epsilon) (where epsilon < 0.01 or so) is used. This 45 | * module maintains this logbase (B). 46 | * 47 | * However, maintaining probabilities in log domain creates a problem 48 | * when adding two probability values. This problem can be solved by 49 | * table lookup. Note that: 50 | * 51 | * - \f$ b^z = b^x + b^y \f$ 52 | * - \f$ b^z = b^x(1 + b^{y-x}) = b^y(1 + e^{x-y}) \f$ 53 | * - \f$ z = x + log_b(1 + b^{y-x}) = y + log_b(1 + b^{x-y}) \f$ 54 | * 55 | * So: 56 | * 57 | * - when \f$ y > x, z = y + logadd\_table[-(x-y)] \f$ 58 | * - when \f$ x > y, z = x + logadd\_table[-(y-x)] \f$ 59 | * - where \f$ logadd\_table[n] = log_b(1 + b^{-n}) \f$ 60 | * 61 | * The first entry in logadd_table is 62 | * simply \f$ log_b(2.0) \f$, for 63 | * the case where \f$ y = x \f$ and thus 64 | * \f$ z = log_b(2x) = log_b(2) + x \f$. The last entry is zero, 65 | * where \f$ log_b(x+y) = x = y \f$ due to loss of precision. 66 | * 67 | * Since this table can be quite large particularly for small 68 | * logbases, an option is provided to compress it by dropping the 69 | * least significant bits of the table. 70 | */ 71 | 72 | #ifndef __LOGMATH_H__ 73 | #define __LOGMATH_H__ 74 | 75 | #include 76 | #include 77 | #include 78 | 79 | 80 | #ifdef __cplusplus 81 | extern "C" { 82 | #endif 83 | #if 0 84 | /* Fool Emacs. */ 85 | } 86 | #endif 87 | 88 | /** 89 | * Integer log math computation table. 90 | * 91 | * This is exposed here to allow log-add computations to be inlined. 92 | */ 93 | typedef struct logadd_s logadd_t; 94 | struct logadd_s { 95 | /** Table, in unsigned integers of (width) bytes. */ 96 | void *table; 97 | /** Number of elements in (table). This is never smaller than 256 (important!) */ 98 | uint32 table_size; 99 | /** Width of elements of (table). */ 100 | uint8 width; 101 | /** Right shift applied to elements in (table). */ 102 | int8 shift; 103 | }; 104 | 105 | /** 106 | * Integer log math computation class. 107 | */ 108 | typedef struct logmath_s logmath_t; 109 | 110 | /** 111 | * Obtain the log-add table from a logmath_t * 112 | */ 113 | #define LOGMATH_TABLE(lm) ((logadd_t *)lm) 114 | 115 | /** 116 | * Initialize a log math computation table. 117 | * @param base The base B in which computation is to be done. 118 | * @param shift Log values are shifted right by this many bits. 119 | * @param use_table Whether to use an add table or not 120 | * @return The newly created log math table. 121 | */ 122 | SPHINXBASE_EXPORT 123 | logmath_t *logmath_init(float64 base, int shift, int use_table); 124 | 125 | /** 126 | * Memory-map (or read) a log table from a file. 127 | */ 128 | SPHINXBASE_EXPORT 129 | logmath_t *logmath_read(const char *filename); 130 | 131 | /** 132 | * Write a log table to a file. 133 | */ 134 | SPHINXBASE_EXPORT 135 | int32 logmath_write(logmath_t *lmath, const char *filename); 136 | 137 | /** 138 | * Get the log table size and dimensions. 139 | */ 140 | SPHINXBASE_EXPORT 141 | int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size, 142 | uint32 *out_width, uint32 *out_shift); 143 | 144 | /** 145 | * Get the log base. 146 | */ 147 | SPHINXBASE_EXPORT 148 | float64 logmath_get_base(logmath_t *lmath); 149 | 150 | /** 151 | * Get the smallest possible value represented in this base. 152 | */ 153 | SPHINXBASE_EXPORT 154 | int logmath_get_zero(logmath_t *lmath); 155 | 156 | /** 157 | * Get the width of the values in a log table. 158 | */ 159 | SPHINXBASE_EXPORT 160 | int logmath_get_width(logmath_t *lmath); 161 | 162 | /** 163 | * Get the shift of the values in a log table. 164 | */ 165 | SPHINXBASE_EXPORT 166 | int logmath_get_shift(logmath_t *lmath); 167 | 168 | /** 169 | * Retain ownership of a log table. 170 | * 171 | * @return pointer to retained log table. 172 | */ 173 | SPHINXBASE_EXPORT 174 | logmath_t *logmath_retain(logmath_t *lmath); 175 | 176 | /** 177 | * Free a log table. 178 | * 179 | * @return new reference count (0 if freed completely) 180 | */ 181 | SPHINXBASE_EXPORT 182 | int logmath_free(logmath_t *lmath); 183 | 184 | /** 185 | * Add two values in log space exactly and slowly (without using add table). 186 | */ 187 | SPHINXBASE_EXPORT 188 | int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q); 189 | 190 | /** 191 | * Add two values in log space (i.e. return log(exp(p)+exp(q))) 192 | */ 193 | SPHINXBASE_EXPORT 194 | int logmath_add(logmath_t *lmath, int logb_p, int logb_q); 195 | 196 | /** 197 | * Convert linear floating point number to integer log in base B. 198 | */ 199 | SPHINXBASE_EXPORT 200 | int logmath_log(logmath_t *lmath, float64 p); 201 | 202 | /** 203 | * Convert integer log in base B to linear floating point. 204 | */ 205 | SPHINXBASE_EXPORT 206 | float64 logmath_exp(logmath_t *lmath, int logb_p); 207 | 208 | /** 209 | * Convert natural log (in floating point) to integer log in base B. 210 | */ 211 | SPHINXBASE_EXPORT 212 | int logmath_ln_to_log(logmath_t *lmath, float64 log_p); 213 | 214 | /** 215 | * Convert integer log in base B to natural log (in floating point). 216 | */ 217 | SPHINXBASE_EXPORT 218 | float64 logmath_log_to_ln(logmath_t *lmath, int logb_p); 219 | 220 | /** 221 | * Convert base 10 log (in floating point) to integer log in base B. 222 | */ 223 | SPHINXBASE_EXPORT 224 | int logmath_log10_to_log(logmath_t *lmath, float64 log_p); 225 | 226 | /** 227 | * Convert integer log in base B to base 10 log (in floating point). 228 | */ 229 | SPHINXBASE_EXPORT 230 | float64 logmath_log_to_log10(logmath_t *lmath, int logb_p); 231 | 232 | #ifdef __cplusplus 233 | } 234 | #endif 235 | 236 | 237 | #endif /* __LOGMATH_H__ */ 238 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/matrix.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1997-2000 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /********************************************************************* 38 | * 39 | * File: matrix.h 40 | * 41 | * Description: Matrix and linear algebra functions 42 | * 43 | * Author: 44 | * 45 | *********************************************************************/ 46 | 47 | #ifndef MATRIX_H 48 | #define MATRIX_H 49 | 50 | /** \file matrix.h 51 | * \brief Matrix and linear algebra functions. 52 | * 53 | * This file contains some basic matrix and linear algebra operations. 54 | * In general these operate on positive definite matrices ONLY, 55 | * because all matrices we're likely to encounter are either 56 | * covariance matrices or are derived from them, and therefore a 57 | * non-positive-definite matrix indicates some kind of pathological 58 | * condition. 59 | */ 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | #if 0 64 | /* Fool Emacs. */ 65 | } 66 | #endif 67 | 68 | /* Win32/WinCE DLL gunk */ 69 | #include 70 | #include 71 | 72 | 73 | /** 74 | * Norm an array 75 | * @param arr array 76 | * @param d1 dimension 77 | * @param d2 dimension 78 | * @param d3 dimension 79 | **/ 80 | SPHINXBASE_EXPORT void norm_3d(float32 ***arr, uint32 d1, uint32 d2, uint32 d3); 81 | 82 | /** 83 | * Floor 3-d array 84 | * @param out output array 85 | * @para in input array 86 | * @param d1 dimension 87 | * @param d2 dimension 88 | * @param d3 dimension 89 | **/ 90 | SPHINXBASE_EXPORT void 91 | accum_3d(float32 ***out, float32 ***in, uint32 d1, uint32 d2, uint32 d3); 92 | 93 | /** Ensures that non-zero values x such that -band < x < band, band > 0 are set to -band if x < 0 and band if x > 0. 94 | * @param v array 95 | * @param d1 array size 96 | * @param band band value 97 | */ 98 | SPHINXBASE_EXPORT void band_nz_1d(float32 *v, uint32 d1, float32 band); 99 | 100 | /** 101 | * Floor 3-d array 102 | * @param m array 103 | * @param d1 dimension 104 | * @param d2 dimension 105 | * @param d3 dimension 106 | * @param floor floor value 107 | **/ 108 | SPHINXBASE_EXPORT void floor_nz_3d(float32 ***m, uint32 d1, uint32 d2, uint32 d3, float32 floor); 109 | 110 | /** 111 | * Floor 1-d array 112 | * @param m array 113 | * @param d1 dimension 114 | * @param floor floor value 115 | **/ 116 | SPHINXBASE_EXPORT void floor_nz_1d(float32 *v, uint32 d1, float32 floor); 117 | 118 | /** 119 | * Calculate the determinant of a positive definite matrix. 120 | * @param a The input matrix, must be positive definite. 121 | * @param len The dimension of the input matrix. 122 | * @return The determinant of the input matrix, or -1.0 if the matrix is 123 | * not positive definite. 124 | * 125 | * \note These can be vanishingly small hence the float64 return type. 126 | * Also note that only the upper triangular portion of a is 127 | * considered, therefore the check for positive-definiteness is not 128 | * reliable. 129 | **/ 130 | SPHINXBASE_EXPORT 131 | float64 determinant(float32 **a, int32 len); 132 | 133 | /** 134 | * Invert (if possible) a positive definite matrix. 135 | * @param out_ainv The inverse of a will be stored here. 136 | * @param a The input matrix, must be positive definite. 137 | * @param len The dimension of the input matrix. 138 | * @return 0 for success or -1 for a non-positive-definite matrix. 139 | * 140 | * \note Only the upper triangular portion of a is considered, 141 | * therefore the check for positive-definiteness is not reliable. 142 | **/ 143 | SPHINXBASE_EXPORT 144 | int32 invert(float32 **out_ainv, float32 **a, int32 len); 145 | 146 | /** 147 | * Solve (if possible) a positive-definite system of linear equations AX=B for X. 148 | * @param a The A matrix on the left-hand side of the equation, must be positive-definite. 149 | * @param b The B vector on the right-hand side of the equation. 150 | * @param out_x The X vector will be stored here. 151 | * @param n The dimension of the A matrix (n by n) and the B and X vectors. 152 | * @return 0 for success or -1 for a non-positive-definite matrix. 153 | * 154 | * \note Only the upper triangular portion of a is considered, 155 | * therefore the check for positive-definiteness is not reliable. 156 | **/ 157 | SPHINXBASE_EXPORT 158 | int32 solve(float32 **a, float32 *b, 159 | float32 *out_x, int32 n); 160 | 161 | /** 162 | * Calculate the outer product of two vectors. 163 | * @param out_a A (pre-allocated) len x len array. The outer product 164 | * will be stored here. 165 | * @param x A vector of length len. 166 | * @param y A vector of length len. 167 | * @param len The length of the input vectors. 168 | **/ 169 | SPHINXBASE_EXPORT 170 | void outerproduct(float32 **out_a, float32 *x, float32 *y, int32 len); 171 | 172 | /** 173 | * Multiply C=AB where A and B are symmetric matrices. 174 | * @param out_c The output matrix C. 175 | * @param a The input matrix A. 176 | * @param b The input matrix B. 177 | * @param n Dimensionality of A and B. 178 | **/ 179 | SPHINXBASE_EXPORT 180 | void matrixmultiply(float32 **out_c, /* = */ 181 | float32 **a, /* * */ float32 **b, 182 | int32 n); 183 | 184 | /** 185 | * Multiply a symmetric matrix by a constant in-place. 186 | * @param inout_a The matrix to multiply. 187 | * @param x The constant to multiply it by. 188 | * @param n dimension of a. 189 | **/ 190 | SPHINXBASE_EXPORT 191 | void scalarmultiply(float32 **inout_a, float32 x, int32 n); 192 | 193 | /** 194 | * Add A += B. 195 | * @param inout_a The A matrix to add. 196 | * @param b The B matrix to add to A. 197 | * @param n dimension of a and b. 198 | **/ 199 | SPHINXBASE_EXPORT 200 | void matrixadd(float32 **inout_a, float32 **b, int32 n); 201 | 202 | #if 0 203 | { /* Fool indent. */ 204 | #endif 205 | #ifdef __cplusplus 206 | } 207 | #endif 208 | 209 | #endif /* MATRIX_H */ 210 | 211 | /* 212 | * Log record. Maintained by RCS. 213 | * 214 | * $Log$ 215 | * Revision 1.4 2004/07/21 17:46:09 egouvea 216 | * Changed the license terms to make it the same as sphinx2 and sphinx3. 217 | * 218 | * Revision 1.3 2001/04/05 20:02:30 awb 219 | * *** empty log message *** 220 | * 221 | * Revision 1.2 2000/09/29 22:35:12 awb 222 | * *** empty log message *** 223 | * 224 | * Revision 1.1 2000/09/24 21:38:30 awb 225 | * *** empty log message *** 226 | * 227 | * Revision 1.1 97/07/16 11:39:10 eht 228 | * Initial revision 229 | * 230 | * 231 | */ 232 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/mmio.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2006-2007 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /** 38 | * @file mmio.h 39 | * @brief Memory-mapped I/O wrappers for files. 40 | * @author David Huggins-Daines 41 | **/ 42 | 43 | #ifndef __MMIO_H__ 44 | #define __MMIO_H__ 45 | 46 | #include 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | #if 0 52 | /* Fool Emacs. */ 53 | } 54 | #endif 55 | 56 | /** 57 | * Abstract structure representing a memory-mapped file. 58 | **/ 59 | typedef struct mmio_file_s mmio_file_t; 60 | 61 | /** 62 | * Memory-map a file for reading. 63 | * @return a mmio_file_t * or NULL for failure. 64 | **/ 65 | SPHINXBASE_EXPORT 66 | mmio_file_t *mmio_file_read(const char *filename); 67 | 68 | /** 69 | * Get a pointer to the memory mapped for a file. 70 | **/ 71 | SPHINXBASE_EXPORT 72 | void *mmio_file_ptr(mmio_file_t *mf); 73 | 74 | /** 75 | * Unmap a file, releasing memory associated with it. 76 | **/ 77 | SPHINXBASE_EXPORT 78 | void mmio_file_unmap(mmio_file_t *mf); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | 85 | #endif /* __MMIO_H__ */ 86 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/mulaw.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2001 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * muLaw.h -- Table for converting mu-law data into 16-bit linear PCM format. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1996 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * 49 | * 21-Jul-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 50 | * Created from Sunil Issar's version. 51 | */ 52 | 53 | /** 54 | * \file mulaw.h 55 | * \brief Table for converting mu-law data into 16-bit linear PCM format. 56 | */ 57 | 58 | 59 | #ifndef _MULAW_H_ 60 | #define _MULAW_H_ 61 | 62 | 63 | static int16 muLaw[256] = { 64 | -0x1f5f, -0x1e5f, -0x1d5f, -0x1c5f, -0x1b5f, -0x1a5f, -0x195f, -0x185f, 65 | -0x175f, -0x165f, -0x155f, -0x145f, -0x135f, -0x125f, -0x115f, -0x105f, 66 | -0x0f9f, -0x0f1f, -0x0e9f, -0x0e1f, -0x0d9f, -0x0d1f, -0x0c9f, -0x0c1f, 67 | -0x0b9f, -0x0b1f, -0x0a9f, -0x0a1f, -0x099f, -0x091f, -0x089f, -0x081f, 68 | -0x07bf, -0x077f, -0x073f, -0x06ff, -0x06bf, -0x067f, -0x063f, -0x05ff, 69 | -0x05bf, -0x057f, -0x053f, -0x04ff, -0x04bf, -0x047f, -0x043f, -0x03ff, 70 | -0x03cf, -0x03af, -0x038f, -0x036f, -0x034f, -0x032f, -0x030f, -0x02ef, 71 | -0x02cf, -0x02af, -0x028f, -0x026f, -0x024f, -0x022f, -0x020f, -0x01ef, 72 | -0x01d7, -0x01c7, -0x01b7, -0x01a7, -0x0197, -0x0187, -0x0177, -0x0167, 73 | -0x0157, -0x0147, -0x0137, -0x0127, -0x0117, -0x0107, -0x00f7, -0x00e7, 74 | -0x00db, -0x00d3, -0x00cb, -0x00c3, -0x00bb, -0x00b3, -0x00ab, -0x00a3, 75 | -0x009b, -0x0093, -0x008b, -0x0083, -0x007b, -0x0073, -0x006b, -0x0063, 76 | -0x005d, -0x0059, -0x0055, -0x0051, -0x004d, -0x0049, -0x0045, -0x0041, 77 | -0x003d, -0x0039, -0x0035, -0x0031, -0x002d, -0x0029, -0x0025, -0x0021, 78 | -0x001e, -0x001c, -0x001a, -0x0018, -0x0016, -0x0014, -0x0012, -0x0010, 79 | -0x000e, -0x000c, -0x000a, -0x0008, -0x0006, -0x0004, -0x0002, 0x0000, 80 | 0x1f5f, 0x1e5f, 0x1d5f, 0x1c5f, 0x1b5f, 0x1a5f, 0x195f, 0x185f, 81 | 0x175f, 0x165f, 0x155f, 0x145f, 0x135f, 0x125f, 0x115f, 0x105f, 82 | 0x0f9f, 0x0f1f, 0x0e9f, 0x0e1f, 0x0d9f, 0x0d1f, 0x0c9f, 0x0c1f, 83 | 0x0b9f, 0x0b1f, 0x0a9f, 0x0a1f, 0x099f, 0x091f, 0x089f, 0x081f, 84 | 0x07bf, 0x077f, 0x073f, 0x06ff, 0x06bf, 0x067f, 0x063f, 0x05ff, 85 | 0x05bf, 0x057f, 0x053f, 0x04ff, 0x04bf, 0x047f, 0x043f, 0x03ff, 86 | 0x03cf, 0x03af, 0x038f, 0x036f, 0x034f, 0x032f, 0x030f, 0x02ef, 87 | 0x02cf, 0x02af, 0x028f, 0x026f, 0x024f, 0x022f, 0x020f, 0x01ef, 88 | 0x01d7, 0x01c7, 0x01b7, 0x01a7, 0x0197, 0x0187, 0x0177, 0x0167, 89 | 0x0157, 0x0147, 0x0137, 0x0127, 0x0117, 0x0107, 0x00f7, 0x00e7, 90 | 0x00db, 0x00d3, 0x00cb, 0x00c3, 0x00bb, 0x00b3, 0x00ab, 0x00a3, 91 | 0x009b, 0x0093, 0x008b, 0x0083, 0x007b, 0x0073, 0x006b, 0x0063, 92 | 0x005d, 0x0059, 0x0055, 0x0051, 0x004d, 0x0049, 0x0045, 0x0041, 93 | 0x003d, 0x0039, 0x0035, 0x0031, 0x002d, 0x0029, 0x0025, 0x0021, 94 | 0x001e, 0x001c, 0x001a, 0x0018, 0x0016, 0x0014, 0x0012, 0x0010, 95 | 0x000e, 0x000c, 0x000a, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 96 | }; 97 | 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/pio.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * pio.h -- Packaged I/O routines. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: pio.h,v $ 49 | * Revision 1.3 2005/06/22 08:00:09 arthchan2003 50 | * Completed all doxygen documentation on file description for libs3decoder/libutil/libs3audio and programs. 51 | * 52 | * Revision 1.2 2005/06/22 03:09:52 arthchan2003 53 | * 1, Fixed doxygen documentation, 2, Added keyword. 54 | * 55 | * Revision 1.2 2005/06/16 00:14:08 archan 56 | * Added const keyword to file argument for file_open 57 | * 58 | * Revision 1.1 2005/06/15 06:11:03 archan 59 | * sphinx3 to s3.generic: change io.[ch] to pio.[ch] 60 | * 61 | * Revision 1.5 2005/06/15 04:21:46 archan 62 | * 1, Fixed doxygen-documentation, 2, Add keyword such that changes will be logged into a file. 63 | * 64 | * Revision 1.4 2005/04/20 03:49:32 archan 65 | * Add const to string argument of myfopen. 66 | * 67 | * Revision 1.3 2005/03/30 01:22:48 archan 68 | * Fixed mistakes in last updates. Add 69 | * 70 | * 71 | * 08-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 72 | * Added stat_mtime(). 73 | * 74 | * 11-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 75 | * Added _myfopen() and myfopen macro. 76 | * 77 | * 05-Sep-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 78 | * Started. 79 | */ 80 | 81 | 82 | #ifndef _LIBUTIL_IO_H_ 83 | #define _LIBUTIL_IO_H_ 84 | 85 | #include 86 | #if !defined(_WIN32_WCE) && !(defined(__ADSPBLACKFIN__) && !defined(__linux__)) 87 | #include 88 | #endif 89 | 90 | /* Win32/WinCE DLL gunk */ 91 | #include 92 | #include 93 | 94 | /** \file pio.h 95 | * \brief file IO related operations. 96 | * 97 | * Custom fopen with error checking is implemented. fopen_comp can 98 | * open a file with .z, .Z, .gz or .GZ extension 99 | * 100 | * WARNING: Usage of stat_retry will results in 100s of waiting time 101 | * if the file doesn't exist. 102 | */ 103 | 104 | #ifdef __cplusplus 105 | extern "C" { 106 | #endif 107 | #if 0 108 | /* Fool Emacs. */ 109 | } 110 | #endif 111 | 112 | /** 113 | * Like fopen, but use popen and zcat if it is determined that "file" is compressed 114 | * (i.e., has a .z, .Z, .gz, or .GZ extension). 115 | */ 116 | SPHINXBASE_EXPORT 117 | FILE *fopen_comp (const char *file, /**< In: File to be opened */ 118 | const char *mode, /**< In: "r" or "w", as with normal fopen */ 119 | int32 *ispipe /**< Out: On return *ispipe is TRUE iff file 120 | was opened via a pipe */ 121 | ); 122 | 123 | /** 124 | * Close a file opened using fopen_comp. 125 | */ 126 | SPHINXBASE_EXPORT 127 | void fclose_comp (FILE *fp, /**< In: File pointer to be closed */ 128 | int32 ispipe /**< In: ispipe argument that was returned by the 129 | corresponding fopen_comp() call */ 130 | ); 131 | 132 | /** 133 | * Open a file for reading, but if file not present try to open compressed version (if 134 | * file is uncompressed, and vice versa). 135 | */ 136 | SPHINXBASE_EXPORT 137 | FILE *fopen_compchk (const char *file, /**< In: File to be opened */ 138 | int32 *ispipe /**< Out: On return *ispipe is TRUE iff file 139 | was opened via a pipe */ 140 | ); 141 | 142 | /** 143 | * Wrapper around fopen to check for failure and E_FATAL if failed. 144 | */ 145 | SPHINXBASE_EXPORT 146 | FILE *_myfopen(const char *file, const char *mode, 147 | const char *pgm, int32 line); /* In: __FILE__, __LINE__ from where called */ 148 | #define myfopen(file,mode) _myfopen((file),(mode),__FILE__,__LINE__) 149 | 150 | 151 | /** 152 | * NFS file reads seem to fail now and then. Use the following functions in place of 153 | * the regular fread. It retries failed freads several times and quits only if all of 154 | * them fail. Be aware, however, that even normal failures such as attempting to read 155 | * beyond EOF will trigger such retries, wasting about a minute in retries. 156 | * Arguments identical to regular fread. 157 | */ 158 | SPHINXBASE_EXPORT 159 | int32 fread_retry(void *pointer, int32 size, int32 num_items, FILE *stream); 160 | 161 | /** 162 | * Read a line of arbitrary length from a file and return it as a 163 | * newly allocated string. 164 | * 165 | * @deprecated Use line iterators instead. 166 | * 167 | * @param stream The file handle to read from. 168 | * @param out_len Output: if not NULL, length of the string read. 169 | * @return allocated string containing the line, or NULL on error or EOF. 170 | */ 171 | SPHINXBASE_EXPORT 172 | char *fread_line(FILE *stream, size_t *out_len); 173 | 174 | /** 175 | * Line iterator for files. 176 | */ 177 | typedef struct lineiter_t { 178 | char *buf; 179 | FILE *fh; 180 | int32 bsiz; 181 | int32 len; 182 | int32 clean; 183 | int32 lineno; 184 | } lineiter_t; 185 | 186 | /** 187 | * Start reading lines from a file. 188 | */ 189 | SPHINXBASE_EXPORT 190 | lineiter_t *lineiter_start(FILE *fh); 191 | 192 | /** 193 | * Start reading lines from a file, skip comments and trim lines. 194 | */ 195 | SPHINXBASE_EXPORT 196 | lineiter_t *lineiter_start_clean(FILE *fh); 197 | 198 | /** 199 | * Move to the next line in the file. 200 | */ 201 | SPHINXBASE_EXPORT 202 | lineiter_t *lineiter_next(lineiter_t *li); 203 | 204 | /** 205 | * Stop reading lines from a file. 206 | */ 207 | SPHINXBASE_EXPORT 208 | void lineiter_free(lineiter_t *li); 209 | 210 | /** 211 | * Returns current line number. 212 | */ 213 | SPHINXBASE_EXPORT 214 | int lineiter_lineno(lineiter_t *li); 215 | 216 | 217 | #ifdef _WIN32_WCE 218 | /* Fake this for WinCE which has no stat() */ 219 | #include 220 | struct stat { 221 | DWORD st_mtime; 222 | DWORD st_size; 223 | }; 224 | #endif /* _WIN32_WCE */ 225 | 226 | #if defined(__ADSPBLACKFIN__) && !defined(__linux__) 227 | struct stat { 228 | int32 st_mtime; 229 | int32 st_size; 230 | }; 231 | 232 | #endif 233 | 234 | /** 235 | * Bitstream encoder - for writing compressed files. 236 | */ 237 | typedef struct bit_encode_s bit_encode_t; 238 | 239 | /** 240 | * Attach bitstream encoder to a file. 241 | */ 242 | bit_encode_t *bit_encode_attach(FILE *outfh); 243 | 244 | /** 245 | * Retain pointer to a bit encoder. 246 | */ 247 | bit_encode_t *bit_encode_retain(bit_encode_t *be); 248 | 249 | /** 250 | * Release pointer to a bit encoder. 251 | * 252 | * Note that this does NOT flush any leftover bits. 253 | */ 254 | int bit_encode_free(bit_encode_t *be); 255 | 256 | /** 257 | * Write bits to encoder. 258 | */ 259 | int bit_encode_write(bit_encode_t *be, unsigned char const *bits, int nbits); 260 | 261 | /** 262 | * Write lowest-order bits of codeword to encoder. 263 | */ 264 | int bit_encode_write_cw(bit_encode_t *be, uint32 codeword, int nbits); 265 | 266 | /** 267 | * Flush any unwritten bits, zero-padding if necessary. 268 | */ 269 | int bit_encode_flush(bit_encode_t *be); 270 | 271 | /** 272 | * There is no bitstream decoder, because a stream abstraction is too 273 | * slow. Instead we read blocks of bits and treat them as bitvectors. 274 | */ 275 | 276 | /** 277 | * Like fread_retry, but for stat. Arguments identical to regular stat. 278 | * Return value: 0 if successful, -1 if stat failed several attempts. 279 | */ 280 | SPHINXBASE_EXPORT 281 | int32 stat_retry (const char *file, struct stat *statbuf); 282 | 283 | /** 284 | * Return time of last modification for the given file, or -1 if stat fails. 285 | */ 286 | 287 | SPHINXBASE_EXPORT 288 | int32 stat_mtime (const char *file); 289 | 290 | /** 291 | * Create a directory and all of its parent directories, as needed. 292 | * 293 | * @return 0 on success, <0 on failure. 294 | */ 295 | SPHINXBASE_EXPORT 296 | int build_directory(const char *path); 297 | 298 | #ifdef __cplusplus 299 | } 300 | #endif 301 | 302 | #endif 303 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/prim_type.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * prim_type.h -- Primitive types; more machine-independent. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: prim_type.h,v $ 49 | * Revision 1.12 2005/10/05 00:31:14 dhdfu 50 | * Make int8 be explicitly signed (signedness of 'char' is 51 | * architecture-dependent). Then make a bunch of things use uint8 where 52 | * signedness is unimportant, because on the architecture where 'char' is 53 | * unsigned, it is that way for a reason (signed chars are slower). 54 | * 55 | * Revision 1.11 2005/06/22 03:10:23 arthchan2003 56 | * Added keyword. 57 | * 58 | * Revision 1.3 2005/03/30 01:22:48 archan 59 | * Fixed mistakes in last updates. Add 60 | * 61 | * 62 | * 12-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 63 | * Added arraysize_t, point_t, fpoint_t. 64 | * 65 | * 01-Feb-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 66 | * Added anytype_t. 67 | * 68 | * 08-31-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 69 | * Created. 70 | */ 71 | 72 | 73 | #ifndef _LIBUTIL_PRIM_TYPE_H_ 74 | #define _LIBUTIL_PRIM_TYPE_H_ 75 | 76 | /** 77 | * @file prim_type.h 78 | * @brief Basic type definitions used in Sphinx. 79 | */ 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | #if 0 85 | } /* Fool Emacs into not indenting things. */ 86 | #endif 87 | 88 | #include 89 | 90 | /* Define some things for VisualDSP++ */ 91 | #if defined(__ADSPBLACKFIN__) && !defined(__GNUC__) 92 | # ifndef HAVE_LONG_LONG 93 | # define HAVE_LONG_LONG 94 | # endif 95 | # ifndef ssize_t 96 | typedef signed int ssize_t; 97 | # endif 98 | # define SIZEOF_LONG_LONG 8 99 | # define __BIGSTACKVARIABLE__ static 100 | #else /* Not VisualDSP++ */ 101 | # define __BIGSTACKVARIABLE__ 102 | #endif 103 | 104 | /** 105 | * Union of basic types. 106 | */ 107 | typedef union anytype_s { 108 | void *ptr; 109 | long i; 110 | unsigned long ui; 111 | double fl; 112 | } anytype_t; 113 | 114 | /* 115 | * Assume P64 or LP64. If you need to port this to a DSP, let us know. 116 | */ 117 | typedef int int32; 118 | typedef short int16; 119 | typedef signed char int8; 120 | typedef unsigned int uint32; 121 | typedef unsigned short uint16; 122 | typedef unsigned char uint8; 123 | typedef float float32; 124 | typedef double float64; 125 | #if defined(_MSC_VER) 126 | typedef __int64 int64; 127 | typedef unsigned __int64 uint64; 128 | #elif defined(HAVE_LONG_LONG) && (SIZEOF_LONG_LONG == 8) 129 | typedef long long int64; 130 | typedef unsigned long long uint64; 131 | #else /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */ 132 | typedef long long int64; 133 | typedef unsigned long long uint64; 134 | #endif /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */ 135 | 136 | #ifndef TRUE 137 | #define TRUE 1 138 | #endif 139 | #ifndef FALSE 140 | #define FALSE 0 141 | #endif 142 | 143 | #ifndef NULL 144 | #define NULL (void *)0 145 | #endif 146 | 147 | /* These really ought to come from , but not everybody has that. */ 148 | /* Useful constants */ 149 | #define MAX_INT32 ((int32) 0x7fffffff) 150 | #define MAX_INT16 ((int16) 0x00007fff) 151 | #define MAX_INT8 ((int8) 0x0000007f) 152 | 153 | #define MAX_NEG_INT32 ((int32) 0x80000000) 154 | #define MAX_NEG_INT16 ((int16) 0xffff8000) 155 | #define MAX_NEG_INT8 ((int8) 0xffffff80) 156 | 157 | #define MAX_UINT32 ((uint32) 0xffffffff) 158 | #define MAX_UINT16 ((uint16) 0x0000ffff) 159 | #define MAX_UINT8 ((uint8) 0x000000ff) 160 | 161 | /* The following are approximate; IEEE floating point standards might quibble! */ 162 | #define MAX_POS_FLOAT32 3.4e+38f 163 | #define MIN_POS_FLOAT32 1.2e-38f /* But not 0 */ 164 | #define MAX_POS_FLOAT64 1.8e+307 165 | #define MIN_POS_FLOAT64 2.2e-308 166 | 167 | #define MAX_IEEE_NORM_POS_FLOAT32 3.4e+38f 168 | #define MIN_IEEE_NORM_POS_FLOAT32 1.2e-38f 169 | #define MIN_IEEE_NORM_NEG_FLOAT32 -3.4e+38f 170 | #define MAX_IEEE_NORM_POS_FLOAT64 1.8e+307 171 | #define MIN_IEEE_NORM_POS_FLOAT64 2.2e-308 172 | #define MIN_IEEE_NORM_NEG_FLOAT64 -1.8e+307 173 | 174 | /* Will the following really work?? */ 175 | #define MIN_NEG_FLOAT32 ((float32) (-MIN_POS_FLOAT32)) 176 | #define MIN_NEG_FLOAT64 ((float64) (-MIN_POS_FLOAT64)) 177 | 178 | 179 | #ifdef __cplusplus 180 | } 181 | #endif 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/profile.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1999-2001 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /* 38 | * profile.h -- For timing and event counting. 39 | * 40 | * ********************************************** 41 | * CMU ARPA Speech Project 42 | * 43 | * Copyright (c) 1999 Carnegie Mellon University. 44 | * ALL RIGHTS RESERVED. 45 | * ********************************************** 46 | * 47 | * HISTORY 48 | * $Log: profile.h,v $ 49 | * Revision 1.10 2005/06/22 03:10:59 arthchan2003 50 | * 1, Fixed doxygen documentation, 2, Added keyword. 51 | * 52 | * Revision 1.5 2005/06/15 04:21:47 archan 53 | * 1, Fixed doxygen-documentation, 2, Add keyword such that changes will be logged into a file. 54 | * 55 | * Revision 1.4 2005/04/25 19:22:48 archan 56 | * Refactor out the code of rescoring from lexical tree. Potentially we want to turn off the rescoring if we need. 57 | * 58 | * Revision 1.3 2005/03/30 01:22:48 archan 59 | * Fixed mistakes in last updates. Add 60 | * 61 | * 62 | * 11-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 63 | * Added ptmr_init(). 64 | * 65 | * 19-Jun-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 66 | * Created from earlier Sphinx-3 version. 67 | */ 68 | 69 | 70 | #ifndef _LIBUTIL_PROFILE_H_ 71 | #define _LIBUTIL_PROFILE_H_ 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif 76 | #if 0 77 | } /* Fool Emacs into not indenting things. */ 78 | #endif 79 | 80 | /** \file profile.h 81 | * \brief Implementation of profiling, include counting , timing, cpu clock checking 82 | * 83 | * Currently, function host_endian is also in this function. It is 84 | * not documented. 85 | */ 86 | 87 | #include 88 | 89 | /* Win32/WinCE DLL gunk */ 90 | #include 91 | #include 92 | 93 | 94 | /** 95 | * \struct pctr_t 96 | * 97 | * Generic event counter for profiling. User is responsible for allocating an array 98 | * of the desired number. There should be a sentinel with name = NULL. 99 | */ 100 | typedef struct { 101 | char *name; /**< Counter print name; NULL 102 | terminates array of counters 103 | Used by pctr_print_all */ 104 | int32 count; /**< Counter value */ 105 | } pctr_t; 106 | 107 | /** 108 | * operations of pctr_t 109 | */ 110 | 111 | /** 112 | * Initialize a counter 113 | * @return an initialized counter 114 | */ 115 | SPHINXBASE_EXPORT 116 | pctr_t* pctr_new ( 117 | char *name /**< The name of the counter */ 118 | ); 119 | 120 | /** 121 | * Reset a counter 122 | */ 123 | 124 | SPHINXBASE_EXPORT 125 | void pctr_reset (pctr_t *ctr /**< A pointer of a counter */ 126 | ); 127 | 128 | /** 129 | * Print a counter 130 | */ 131 | SPHINXBASE_EXPORT 132 | void pctr_print(FILE *fp, /**< A file pointer */ 133 | pctr_t *ctr /**< A pointer of a counter */ 134 | ); 135 | 136 | /** 137 | * Increment a counter 138 | */ 139 | SPHINXBASE_EXPORT 140 | void pctr_increment (pctr_t *ctr, /**< A pointer of a counter */ 141 | int32 inc /**< The increment of the counter */ 142 | ); 143 | 144 | /** 145 | Free the counter 146 | */ 147 | SPHINXBASE_EXPORT 148 | void pctr_free(pctr_t* ctr /**< A pointer of a counter */ 149 | ); 150 | 151 | 152 | /** 153 | * \struct ptmr_t 154 | * Generic timer structures and functions for coarse-grained performance measurements 155 | * using standard system calls. 156 | */ 157 | typedef struct { 158 | const char *name; /**< Timer print name; NULL terminates an array of timers. 159 | Used by ptmr_print_all */ 160 | float64 t_cpu; /**< CPU time accumulated since most recent reset op */ 161 | float64 t_elapsed; /**< Elapsed time accumulated since most recent reset */ 162 | float64 t_tot_cpu; /**< Total CPU time since creation */ 163 | float64 t_tot_elapsed; /**< Total elapsed time since creation */ 164 | float64 start_cpu; /**< ---- FOR INTERNAL USE ONLY ---- */ 165 | float64 start_elapsed; /**< ---- FOR INTERNAL USE ONLY ---- */ 166 | } ptmr_t; 167 | 168 | 169 | 170 | /** Start timing using tmr */ 171 | SPHINXBASE_EXPORT 172 | void ptmr_start (ptmr_t *tmr /**< The timer*/ 173 | ); 174 | 175 | /** Stop timing and accumulate tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed} */ 176 | SPHINXBASE_EXPORT 177 | void ptmr_stop (ptmr_t *tmr /**< The timer*/ 178 | ); 179 | 180 | /** Reset tmr->{t_cpu, t_elapsed} to 0.0 */ 181 | SPHINXBASE_EXPORT 182 | void ptmr_reset (ptmr_t *tmr /**< The timer*/ 183 | ); 184 | 185 | /** Reset tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed} to 0.0 186 | */ 187 | SPHINXBASE_EXPORT 188 | void ptmr_init (ptmr_t *tmr /**< The timer*/ 189 | ); 190 | 191 | 192 | /** 193 | * Reset t_cpu, t_elapsed of all timer modules in array tmr[] to 0.0. 194 | * The array should be terminated with a sentinel with .name = NULL. 195 | */ 196 | SPHINXBASE_EXPORT 197 | void ptmr_reset_all (ptmr_t *tmr /**< The timer*/ 198 | ); 199 | 200 | /** 201 | * Print t_cpu for all timer modules in tmr[], normalized by norm (i.e., t_cpu/norm). 202 | * The array should be terminated with a sentinel with .name = NULL. 203 | */ 204 | SPHINXBASE_EXPORT 205 | void ptmr_print_all (FILE *fp, /**< The file pointer */ 206 | ptmr_t *tmr, /**< The timer*/ 207 | float64 norm 208 | ); 209 | 210 | 211 | /** 212 | * Return the processor clock speed (in MHz); only available on some machines (Alphas). 213 | * The dummy argument can be any integer value. 214 | */ 215 | SPHINXBASE_EXPORT 216 | int32 host_pclk (int32 dummy); 217 | 218 | 219 | /* 220 | * Check the native byte-ordering of the machine by writing a magic 221 | * number to a temporary file and reading it back. * Return value: 222 | * 0 if BIG-ENDIAN, 1 if LITTLE-ENDIAN, -1 if error. 223 | */ 224 | SPHINXBASE_EXPORT 225 | int32 host_endian ( void ); 226 | 227 | #ifdef __cplusplus 228 | } 229 | #endif 230 | 231 | #endif 232 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/sbthread.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2008 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /** 38 | * @file sbthread.h 39 | * @brief Simple portable thread functions. 40 | * @author David Huggins-Daines 41 | **/ 42 | 43 | #ifndef __SBTHREAD_H__ 44 | #define __SBTHREAD_H__ 45 | 46 | #include 47 | 48 | #include 49 | #include 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | #if 0 55 | /* Fool Emacs. */ 56 | } 57 | #endif 58 | 59 | /** 60 | * Thread object. 61 | */ 62 | typedef struct sbthread_s sbthread_t; 63 | 64 | /** 65 | * Asynchronous message queue object. 66 | */ 67 | typedef struct sbmsgq_s sbmsgq_t; 68 | 69 | /** 70 | * Mutex (critical section) object. 71 | */ 72 | typedef struct sbmtx_s sbmtx_t; 73 | 74 | /** 75 | * Event object. 76 | */ 77 | typedef struct sbevent_s sbevent_t; 78 | 79 | /** 80 | * Entry point for a thread. 81 | */ 82 | typedef int (*sbthread_main)(sbthread_t *th); 83 | 84 | /** 85 | * Start a new thread. 86 | */ 87 | SPHINXBASE_EXPORT 88 | sbthread_t *sbthread_start(cmd_ln_t *config, sbthread_main func, void *arg); 89 | 90 | /** 91 | * Wait for a thread to complete. 92 | */ 93 | SPHINXBASE_EXPORT 94 | int sbthread_wait(sbthread_t *th); 95 | 96 | /** 97 | * Free a thread object. 98 | */ 99 | SPHINXBASE_EXPORT 100 | void sbthread_free(sbthread_t *th); 101 | 102 | /** 103 | * Get configuration object from a thread. 104 | */ 105 | SPHINXBASE_EXPORT 106 | cmd_ln_t *sbthread_config(sbthread_t *th); 107 | 108 | /** 109 | * Get argument pointer from a thread. 110 | */ 111 | SPHINXBASE_EXPORT 112 | void *sbthread_arg(sbthread_t *th); 113 | 114 | /** 115 | * Get message queue from a thread. 116 | */ 117 | SPHINXBASE_EXPORT 118 | sbmsgq_t *sbthread_msgq(sbthread_t *th); 119 | 120 | /** 121 | * Wait for a thread to complete. 122 | */ 123 | SPHINXBASE_EXPORT 124 | int sbthread_wait(sbthread_t *th); 125 | 126 | /** 127 | * Send an asynchronous message to a thread. 128 | * 129 | * Each thread gets a message queue by default, so this is just a 130 | * wrapper around sbmsgq_send(). 131 | */ 132 | SPHINXBASE_EXPORT 133 | int sbthread_send(sbthread_t *th, size_t len, void const *data); 134 | 135 | /** 136 | * Create a message queue. 137 | * 138 | * @param depth Depth of the queue. 139 | */ 140 | SPHINXBASE_EXPORT 141 | sbmsgq_t *sbmsgq_init(size_t depth); 142 | 143 | /** 144 | * Free a message queue. 145 | */ 146 | SPHINXBASE_EXPORT 147 | void sbmsgq_free(sbmsgq_t *q); 148 | 149 | /** 150 | * Post a message to a queue. 151 | */ 152 | SPHINXBASE_EXPORT 153 | int sbmsgq_send(sbmsgq_t *q, size_t len, void const *data); 154 | 155 | /** 156 | * Wait for a message from a queue. 157 | */ 158 | SPHINXBASE_EXPORT 159 | void *sbmsgq_wait(sbmsgq_t *q, size_t *out_len, int sec, int nsec); 160 | 161 | /** 162 | * Create a mutex. 163 | */ 164 | SPHINXBASE_EXPORT 165 | sbmtx_t *sbmtx_init(void); 166 | 167 | /** 168 | * Try to acquire a mutex. 169 | */ 170 | SPHINXBASE_EXPORT 171 | int sbmtx_trylock(sbmtx_t *mtx); 172 | 173 | /** 174 | * Acquire a mutex. 175 | */ 176 | SPHINXBASE_EXPORT 177 | int sbmtx_lock(sbmtx_t *mtx); 178 | 179 | /** 180 | * Release a mutex. 181 | */ 182 | SPHINXBASE_EXPORT 183 | int sbmtx_unlock(sbmtx_t *mtx); 184 | 185 | /** 186 | * Dispose of a mutex. 187 | */ 188 | SPHINXBASE_EXPORT 189 | void sbmtx_free(sbmtx_t *mtx); 190 | 191 | /** 192 | * Initialize an event. 193 | */ 194 | SPHINXBASE_EXPORT 195 | sbevent_t *sbevent_init(void); 196 | 197 | /** 198 | * Free an event. 199 | */ 200 | SPHINXBASE_EXPORT 201 | void sbevent_free(sbevent_t *evt); 202 | 203 | /** 204 | * Signal an event. 205 | */ 206 | SPHINXBASE_EXPORT 207 | int sbevent_signal(sbevent_t *evt); 208 | 209 | /** 210 | * Wait for an event to be signalled. 211 | */ 212 | SPHINXBASE_EXPORT 213 | int sbevent_wait(sbevent_t *evt, int sec, int nsec); 214 | 215 | 216 | #ifdef __cplusplus 217 | } 218 | #endif 219 | 220 | 221 | #endif /* __SBTHREAD_H__ */ 222 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/sphinxbase_export.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPHINXBASE_EXPORT_H__ 2 | #define __SPHINXBASE_EXPORT_H__ 3 | 4 | /* Win32/WinCE DLL gunk */ 5 | #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(_WIN32_WP) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__WINSCW__) && !defined(__SYMBIAN32__) 6 | #if defined(SPHINXBASE_EXPORTS) /* Visual Studio */ 7 | #define SPHINXBASE_EXPORT __declspec(dllexport) 8 | #else 9 | #define SPHINXBASE_EXPORT __declspec(dllimport) 10 | #endif 11 | #else /* !_WIN32 */ 12 | #define SPHINXBASE_EXPORT 13 | #endif 14 | 15 | #endif /* __SPHINXBASE_EXPORT_H__ */ 16 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/strfuncs.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1995-2004 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | * 36 | */ 37 | /** 38 | * @file strfuncs.h 39 | * @brief Miscellaneous useful string functions 40 | */ 41 | 42 | #ifndef __SB_STRFUNCS_H__ 43 | #define __SB_STRFUNCS_H__ 44 | 45 | #include 46 | 47 | /* Win32/WinCE DLL gunk */ 48 | #include 49 | #include 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | #if 0 56 | /* Fool Emacs. */ 57 | } 58 | #endif 59 | 60 | /** 61 | * Concatenate a NULL-terminated argument list of strings, returning a 62 | * newly allocated string. 63 | **/ 64 | SPHINXBASE_EXPORT 65 | char *string_join(const char *base, ...); 66 | 67 | /** 68 | * Which end of a string to operate on for string_trim(). 69 | */ 70 | enum string_edge_e { 71 | STRING_START, /**< Beginning of string. */ 72 | STRING_END, /**< End of string. */ 73 | STRING_BOTH /**< Both ends of string. */ 74 | }; 75 | 76 | /** 77 | * Remove whitespace from a string, modifying it in-place. 78 | * 79 | * @param string string to trim, contents will be modified. 80 | * @param which one of STRING_START, STRING_END, or STRING_BOTH. 81 | */ 82 | SPHINXBASE_EXPORT 83 | char *string_trim(char *string, enum string_edge_e which); 84 | 85 | /** 86 | * Locale independent version of atof(). 87 | * 88 | * This function behaves like atof() in the "C" locale. Switching 89 | * locale in a threaded program is extremely uncool, therefore we need 90 | * this since we pass floats as strings in 1000 different places. 91 | */ 92 | SPHINXBASE_EXPORT 93 | double atof_c(char const *str); 94 | 95 | /* FIXME: Both of these string splitting functions basically suck. I 96 | have attempted to fix them as best I can. (dhuggins@cs, 20070808) */ 97 | 98 | /** 99 | * Convert a line to an array of "words", based on whitespace separators. A word 100 | * is a string with no whitespace chars in it. 101 | * Note that the string line is modified as a result: NULL chars are placed after 102 | * every word in the line. 103 | * Return value: No. of words found; -1 if no. of words in line exceeds n_wptr. 104 | */ 105 | SPHINXBASE_EXPORT 106 | int32 str2words (char *line, /**< In/Out: line to be parsed. This 107 | string will be modified! (NUL 108 | characters inserted at word 109 | boundaries) */ 110 | char **wptr, /**< In/Out: Array of pointers to 111 | words found in line. The array 112 | must be allocated by the caller. 113 | It may be NULL in which case the 114 | number of words will be counted. 115 | This allows you to allcate it to 116 | the proper size, e.g.: 117 | 118 | n = str2words(line, NULL, 0); 119 | wptr = ckd_calloc(n, sizeof(*wptr)); 120 | str2words(line, wptr, n); 121 | */ 122 | int32 n_wptr /**< In: Size of wptr array, ignored 123 | if wptr == NULL */ 124 | ); 125 | 126 | /** 127 | * Yet another attempt at a clean "next-word-in-string" function. See arguments below. 128 | * @return Length of word returned, or -1 if nothing found. 129 | * This allows you to scan through a line: 130 | * 131 | *
132 |  * while ((n = nextword(line, delim, &word, &delimfound)) >= 0) {
133 |  *     ... do something with word ..
134 |  *     word[n] = delimfound;
135 |  *     line = word + n;
136 |  * }
137 |  * 
138 | */ 139 | SPHINXBASE_EXPORT 140 | int32 nextword (char *line, /**< Input: String being searched for next word. 141 | Will be modified by this function (NUL characters inserted) */ 142 | const char *delim, /**< Input: A word, if found, must be delimited at either 143 | end by a character from this string (or at the end 144 | by the NULL char) */ 145 | char **word,/**< Output: *word = ptr within line to beginning of first 146 | word, if found. Delimiter at the end of word replaced 147 | with the NULL char. */ 148 | char *delimfound /**< Output: *delimfound = original delimiter found at the end 149 | of the word. (This way, the caller can restore the 150 | delimiter, preserving the original string.) */ 151 | ); 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | 157 | 158 | #endif /* __SB_STRFUNCS_H__ */ 159 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/sphinxbase/yin.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright (c) 2008 Beyond Access, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY BEYOND ACCESS, INC. ``AS IS'' AND ANY 18 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEYOND ACCESS, INC. NOR 21 | * ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * @file yin.h 32 | * @brief Implementation of pitch estimation 33 | * @author David Huggins-Daines 34 | * 35 | * This implements part of the YIN algorithm: 36 | * 37 | * "YIN, a fundamental frequency estimator for speech and music". 38 | * Alain de Cheveigné and Hideki Kawahara. Journal of the Acoustical 39 | * Society of America, 111 (4), April 2002. 40 | */ 41 | 42 | #ifndef __YIN_H__ 43 | #define __YIN_H__ 44 | 45 | #ifdef __cplusplus 46 | extern "C" 47 | #endif 48 | #if 0 49 | } /* Fool Emacs. */ 50 | #endif 51 | 52 | /* Win32/WinCE DLL gunk */ 53 | #include 54 | #include 55 | 56 | /** 57 | * Frame-based moving-window pitch estimator. 58 | */ 59 | typedef struct yin_s yin_t; 60 | 61 | /** 62 | * Initialize moving-window pitch estimation. 63 | */ 64 | SPHINXBASE_EXPORT 65 | yin_t *yin_init(int frame_size, float search_threshold, 66 | float search_range, int smooth_window); 67 | 68 | /** 69 | * Free a moving-window pitch estimator. 70 | */ 71 | SPHINXBASE_EXPORT 72 | void yin_free(yin_t *pe); 73 | 74 | /** 75 | * Start processing an utterance. 76 | */ 77 | SPHINXBASE_EXPORT 78 | void yin_start(yin_t *pe); 79 | 80 | /** 81 | * Mark the end of an utterance. 82 | */ 83 | SPHINXBASE_EXPORT 84 | void yin_end(yin_t *pe); 85 | 86 | /** 87 | * Store a frame of data to the pitch estimator. 88 | * 89 | * @param pe Pitch estimator. 90 | * @param frame Frame of frame_size (see 91 | * yin_init()) samples of audio data. 92 | */ 93 | SPHINXBASE_EXPORT 94 | void yin_store(yin_t *pe, int16 const *frame); 95 | 96 | /** 97 | * Feed a frame of data to the pitch estimator. 98 | * 99 | * @param pe Pitch estimator. 100 | * @param frame Frame of frame_size (see 101 | * yin_init()) samples of audio data. 102 | */ 103 | SPHINXBASE_EXPORT 104 | void yin_write(yin_t *pe, int16 const *frame); 105 | 106 | /** 107 | * Feed stored frame of data to the pitch estimator. 108 | * (see yin_store()) 109 | * 110 | * @param pe Pitch estimator. 111 | */ 112 | SPHINXBASE_EXPORT 113 | void yin_write_stored(yin_t *pe); 114 | 115 | /** 116 | * Read a raw estimated pitch value from the pitch estimator. 117 | * 118 | * @param pe Pitch estimator. 119 | * @param out_period Output: an estimate of the period (*not* the pitch) 120 | * of the signal in samples. 121 | * @param out_bestdiff Output: the minimum normalized difference value 122 | * associated with *out_pitch, in Q15 123 | * format (i.e. scaled by 32768). This can be 124 | * interpreted as one minus the probability of voicing. 125 | * @return Non-zero if enough data was avaliable to return a pitch 126 | * estimate, zero otherwise. 127 | */ 128 | SPHINXBASE_EXPORT 129 | int yin_read(yin_t *pe, uint16 *out_period, float *out_bestdiff); 130 | 131 | #ifdef __cplusplus 132 | } 133 | #endif 134 | 135 | #endif /* __YIN_H__ */ 136 | 137 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/win32/config.h: -------------------------------------------------------------------------------- 1 | /* include/sphinx_config.h, defaults for Win32 */ 2 | /* sphinx_config.h: Externally visible configuration parameters for 3 | * SphinxBase. 4 | */ 5 | 6 | /* Default radix point for fixed-point */ 7 | /* #undef DEFAULT_RADIX */ 8 | 9 | /* Enable thread safety */ 10 | #define ENABLE_THREADS 11 | 12 | /* The Thread Local Storage class */ 13 | #define SPHINXBASE_TLS __declspec(thread) 14 | 15 | /* Use Q15 fixed-point computation */ 16 | /* #undef FIXED16 */ 17 | 18 | /* Use fixed-point computation */ 19 | /* #undef FIXED_POINT */ 20 | 21 | /* Enable matrix algebra with LAPACK */ 22 | #define WITH_LAPACK 23 | 24 | /* The size of `long', as computed by sizeof. */ 25 | #define SIZEOF_LONG 4 26 | 27 | /* We don't have popen, but we do have _popen */ 28 | /* #define HAVE_POPEN 1 */ 29 | 30 | /* We do have perror */ 31 | #define HAVE_PERROR 1 32 | 33 | /* We have sys/stat.h */ 34 | #define HAVE_SYS_STAT_H 1 35 | 36 | /* We do not have unistd.h. */ 37 | #define YY_NO_UNISTD_H 1 38 | 39 | /* Extension for executables */ 40 | #define EXEEXT ".exe" 41 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/win32/sphinx_config.h: -------------------------------------------------------------------------------- 1 | /* include/sphinx_config.h, defaults for Win32 */ 2 | /* sphinx_config.h: Externally visible configuration parameters for 3 | * SphinxBase. 4 | */ 5 | 6 | /* Default radix point for fixed-point */ 7 | /* #undef DEFAULT_RADIX */ 8 | 9 | /* Use Q15 fixed-point computation */ 10 | /* #undef FIXED16 */ 11 | 12 | /* Use fixed-point computation */ 13 | /* #undef FIXED_POINT */ 14 | 15 | /* The size of `long', as computed by sizeof. */ 16 | #define SIZEOF_LONG 4 17 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/wince/assert.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* A bogus for WinCE which sometimes doesn't have it. */ 3 | #ifndef __ASSERT_H__ 4 | #define __ASSERT_H__ 5 | #define assert(x) if (!(x)) (*(int *)0=0); 6 | #endif /* __ASSERT_H__ */ 7 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/wince/config.h: -------------------------------------------------------------------------------- 1 | /* Keep only one configuration file */ 2 | 3 | #include "sphinx_config.h" 4 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/wince/errno.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2007 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * This work was supported in part by funding from the Defense Advanced 19 | * Research Projects Agency and the National Science Foundation of the 20 | * United States of America, and the CMU Sphinx Speech Consortium. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * ==================================================================== 35 | /********************************************************************* 36 | * 37 | * File: errno.h 38 | * 39 | * Description: functions and variables missing from Windows CE standard 40 | * library 41 | * 42 | * Author: Silvio Moioli 43 | * 44 | *********************************************************************/ 45 | 46 | #ifndef __ERRNO_H__ 47 | #define __ERRNO_H__ 48 | 49 | #ifdef __cplusplus 50 | extern "C" extern int errno; 51 | #else 52 | extern int errno; 53 | #endif 54 | 55 | #define EPERM 1 56 | #define ENOENT 2 57 | #define ESRCH 3 58 | #define EINTR 4 59 | #define EIO 5 60 | #define ENXIO 6 61 | #define E2BIG 7 62 | #define ENOEXEC 8 63 | #define EBADF 9 64 | #define ECHILD 10 65 | #define EAGAIN 11 66 | #define ENOMEM 12 67 | #define EACCES 13 68 | #define EFAULT 14 69 | #define EBUSY 16 70 | #define EEXIST 17 71 | #define EXDEV 18 72 | #define ENODEV 19 73 | #define ENOTDIR 20 74 | #define EISDIR 21 75 | #define EINVAL 22 76 | #define ENFILE 23 77 | #define EMFILE 24 78 | #define ENOTTY 25 79 | #define EFBIG 27 80 | #define ENOSPC 28 81 | #define ESPIPE 29 82 | #define EROFS 30 83 | #define EMLINK 31 84 | #define EPIPE 32 85 | #define EDOM 33 86 | #define ERANGE 34 87 | #define EDEADLK 36 88 | #define ENAMETOOLONG 38 89 | #define ENOLCK 39 90 | #define ENOSYS 40 91 | #define ENOTEMPTY 41 92 | #define EILSEQ 42 93 | 94 | #endif /* __ERRNO_H__ */ 95 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Includes/wince/sphinx_config.h: -------------------------------------------------------------------------------- 1 | /* include/sphinx_config.h, defaults for Windows CE. */ 2 | /* sphinx_config.h: Externally visible configuration parameters for 3 | * SphinxBase. 4 | */ 5 | 6 | /* Default radix point for fixed-point */ 7 | /* #undef DEFAULT_RADIX */ 8 | 9 | /* Use Q15 fixed-point computation */ 10 | /* #undef FIXED16 */ 11 | 12 | /* Use fixed-point computation */ 13 | /* #define FIXED_POINT 1 */ 14 | 15 | /* The size of `long', as computed by sizeof. */ 16 | #define SIZEOF_LONG 4 17 | 18 | /* Extension for executables */ 19 | #define EXEEXT ".exe" 20 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libcommon.a -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libopenal.1.17.2.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libopenal.1.17.2.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libopenal.1.dylib: -------------------------------------------------------------------------------- 1 | libopenal.1.17.2.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libopenal.dylib: -------------------------------------------------------------------------------- 1 | libopenal.1.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.3.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.a -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.dylib: -------------------------------------------------------------------------------- 1 | libsphinxad.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxad.la: -------------------------------------------------------------------------------- 1 | # libsphinxad.la - a libtool library file 2 | # Generated by ltmain.sh (GNU libtool) 2.2.6b 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='libsphinxad.3.dylib' 9 | 10 | # Names of this library. 11 | library_names='libsphinxad.3.dylib libsphinxad.dylib' 12 | 13 | # The name of the static archive. 14 | old_library='libsphinxad.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags=' -framework OpenAL' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' /usr/local/lib/libsphinxbase.la -lpthread -lm -lblas -llapack' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libsphinxad. 26 | current=3 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/usr/local/lib' 42 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.3.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.a -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.dylib: -------------------------------------------------------------------------------- 1 | libsphinxbase.3.dylib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/osx/libsphinxbase.la: -------------------------------------------------------------------------------- 1 | # libsphinxbase.la - a libtool library file 2 | # Generated by ltmain.sh (GNU libtool) 2.2.6b 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='libsphinxbase.3.dylib' 9 | 10 | # Names of this library. 11 | library_names='libsphinxbase.3.dylib libsphinxbase.dylib' 12 | 13 | # The name of the static archive. 14 | old_library='libsphinxbase.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags=' ' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' -lpthread -lm -lblas -llapack' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libsphinxbase. 26 | current=3 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/usr/local/lib' 42 | -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x64/sphinxbase.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x64/sphinxbase.dll -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x64/sphinxbase.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x64/sphinxbase.lib -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x86/sphinxbase.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x86/sphinxbase.dll -------------------------------------------------------------------------------- /Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x86/sphinxbase.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanecolb/sphinx-ue4/524bde8a4ceebc446a70e0e0dde66904e1eb4f52/Plugins/SpeechRecognition/ThirdParty/SphinxBase/Libraries/x86/sphinxbase.lib -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sphinx-UE4 2 | Sphinx-UE4 is a speech recognition plugin for Unreal Engine 4. 3 | The plugin makes use of the Pocketsphinx library. 4 | 5 | Note: 6 | This plugin uses a slightly modified version of PocketSphinx, to support passing in a set of keywords, dynamically. 7 | The modified code is contained within the _other folder. 8 | 9 | # Information 10 | Please read https://wiki.unrealengine.com/Speech_Recognition_Plugin for usage information. 11 | 12 | I would love any feedback/advice on the plugin. 13 | Feel free to fork the code, or to contact me at shane.colbert@gmail.com 14 | -------------------------------------------------------------------------------- /_other/PocketSphinx/src/libpocketsphinx/kws_search.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2013 Carnegie Mellon University. All rights 4 | * reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 20 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 23 | * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * ==================================================================== 32 | * 33 | */ 34 | 35 | /* 36 | * kws_search.h -- Search structures for keyword spotting. 37 | */ 38 | 39 | #ifndef __KWS_SEARCH_H__ 40 | #define __KWS_SEARCH_H__ 41 | 42 | /* SphinxBase headers. */ 43 | #include 44 | #include 45 | 46 | /* Local headers. */ 47 | #include "pocketsphinx_internal.h" 48 | #include "kws_detections.h" 49 | #include "hmm.h" 50 | 51 | /** 52 | * Segmentation "iterator" for KWS history. 53 | */ 54 | typedef struct kws_seg_s { 55 | ps_seg_t base; /**< Base structure. */ 56 | gnode_t *detection; /**< Keyword detection correspondent to segment. */ 57 | } kws_seg_t; 58 | 59 | typedef struct kws_keyword_s { 60 | char* word; 61 | int32 threshold; 62 | hmm_t* hmms; 63 | int32 n_hmms; 64 | } kws_keyword_t; 65 | 66 | /** 67 | * Implementation of KWS search structure. 68 | */ 69 | typedef struct kws_search_s { 70 | ps_search_t base; 71 | 72 | hmm_context_t *hmmctx; /**< HMM context. */ 73 | 74 | kws_detections_t *detections; /**< Keyword spotting history */ 75 | kws_keyword_t* keyphrases; /**< Keyphrases to spot */ 76 | int n_keyphrases; /**< Keyphrases amount */ 77 | frame_idx_t frame; /**< Frame index */ 78 | 79 | int32 beam; 80 | 81 | int32 plp; /**< Phone loop probability */ 82 | int32 bestscore; /**< For beam pruning */ 83 | int32 def_threshold; /**< default threshold for p(hyp)/p(altern) ratio */ 84 | 85 | int32 n_pl; /**< Number of CI phones */ 86 | hmm_t *pl_hmms; /**< Phone loop hmms - hmms of CI phones */ 87 | 88 | } kws_search_t; 89 | 90 | /** 91 | * Create, initialize and return a search module. Gets keywords either 92 | * from keyphrase or from a keyphrase file. 93 | */ 94 | ps_search_t *kws_search_init(const char *keyphrase[], int32 *tollerence, int keycount, 95 | const char *keyfile, 96 | cmd_ln_t * config, 97 | acmod_t * acmod, 98 | dict_t * dict, dict2pid_t * d2p); 99 | 100 | /** 101 | * Deallocate search structure. 102 | */ 103 | void kws_search_free(ps_search_t * search); 104 | 105 | /** 106 | * Update KWS search module for new key phrase. 107 | */ 108 | int kws_search_reinit(ps_search_t * kwss, dict_t * dict, dict2pid_t * d2p); 109 | 110 | /** 111 | * Prepare the KWS search structure for beginning decoding of the next 112 | * utterance. 113 | */ 114 | int kws_search_start(ps_search_t * search); 115 | 116 | /** 117 | * Step one frame forward through the Viterbi search. 118 | */ 119 | int kws_search_step(ps_search_t * search, int frame_idx); 120 | 121 | /** 122 | * Windup and clean the KWS search structure after utterance. 123 | */ 124 | int kws_search_finish(ps_search_t * search); 125 | 126 | /** 127 | * Get hypothesis string from the KWS search. 128 | */ 129 | char const *kws_search_hyp(ps_search_t * search, int32 * out_score, 130 | int32 * out_is_final); 131 | /** 132 | * Get active keyphrases 133 | */ 134 | char* kws_search_get_keywords(ps_search_t * search); 135 | 136 | #endif /* __KWS_SEARCH_H__ */ 137 | --------------------------------------------------------------------------------