Fix building for .Net (#463)
This commit is contained in:
3
scripts/dotnet/examples/README.md
Normal file
3
scripts/dotnet/examples/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Introduction
|
||||
|
||||
Files in this directory are used exclusively by CI.
|
||||
20
scripts/dotnet/examples/offline-decode-files.csproj
Normal file
20
scripts/dotnet/examples/offline-decode-files.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>offline_decode_files</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<RestoreSources>/tmp/packages;$(RestoreSources);https://api.nuget.org/v3/index.json</RestoreSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
21
scripts/dotnet/examples/online-decode-files.csproj
Normal file
21
scripts/dotnet/examples/online-decode-files.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>online_decode_files</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<RestoreSources>/tmp/packages;$(RestoreSources);https://api.nuget.org/v3/index.json</RestoreSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>speech_recognition_from_microphone</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<RestoreSources>/tmp/packages;$(RestoreSources);https://api.nuget.org/v3/index.json</RestoreSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="*" />
|
||||
<PackageReference Include="PortAudioSharp2" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -33,12 +33,18 @@ def get_dict():
|
||||
|
||||
def process_linux(s):
|
||||
libs = [
|
||||
"libespeak-ng.so",
|
||||
"libkaldi-decoder-core.so",
|
||||
"libkaldi-native-fbank-core.so",
|
||||
"libonnxruntime.so.1.16.2",
|
||||
"libonnxruntime.so.1.16.3",
|
||||
"libpiper_phonemize.so.1",
|
||||
"libsherpa-onnx-c-api.so",
|
||||
"libsherpa-onnx-core.so",
|
||||
"libsherpa-onnx-fst.so.6",
|
||||
"libsherpa-onnx-kaldifst-core.so",
|
||||
"libucd.so",
|
||||
]
|
||||
prefix = f"{SHERPA_ONNX_DIR}/linux/sherpa_onnx/lib/"
|
||||
prefix = "/tmp/linux/"
|
||||
libs = [prefix + lib for lib in libs]
|
||||
libs = "\n ;".join(libs)
|
||||
|
||||
@@ -55,12 +61,18 @@ def process_linux(s):
|
||||
|
||||
def process_macos(s):
|
||||
libs = [
|
||||
"libespeak-ng.dylib",
|
||||
"libkaldi-decoder-core.dylib",
|
||||
"libkaldi-native-fbank-core.dylib",
|
||||
"libonnxruntime.1.16.2.dylib",
|
||||
"libonnxruntime.1.16.3.dylib",
|
||||
"libpiper_phonemize.1.dylib",
|
||||
"libsherpa-onnx-c-api.dylib",
|
||||
"libsherpa-onnx-core.dylib",
|
||||
"libsherpa-onnx-fst.6.dylib",
|
||||
"libsherpa-onnx-kaldifst-core.dylib",
|
||||
"libucd.dylib",
|
||||
]
|
||||
prefix = f"{SHERPA_ONNX_DIR}/macos/sherpa_onnx/lib/"
|
||||
prefix = f"/tmp/macos/"
|
||||
libs = [prefix + lib for lib in libs]
|
||||
libs = "\n ;".join(libs)
|
||||
|
||||
@@ -77,30 +89,23 @@ def process_macos(s):
|
||||
|
||||
def process_windows(s):
|
||||
libs = [
|
||||
"espeak-ng.dll",
|
||||
"kaldi-decoder-core.dll",
|
||||
"kaldi-native-fbank-core.dll",
|
||||
"onnxruntime.dll",
|
||||
"piper_phonemize.dll",
|
||||
"sherpa-onnx-c-api.dll",
|
||||
"sherpa-onnx-core.dll",
|
||||
"sherpa-onnx-fst.lib",
|
||||
"sherpa-onnx-kaldifst-core.lib",
|
||||
"ucd.dll",
|
||||
]
|
||||
|
||||
version = get_version()
|
||||
|
||||
prefix1 = f"{SHERPA_ONNX_DIR}/windows/sherpa_onnx/lib/"
|
||||
prefix2 = f"{SHERPA_ONNX_DIR}/windows/sherpa_onnx/"
|
||||
prefix3 = f"{SHERPA_ONNX_DIR}/windows/"
|
||||
prefix4 = f"{SHERPA_ONNX_DIR}/windows/sherpa_onnx-{version}.data/data/bin/"
|
||||
print(prefix1, prefix2, prefix3, prefix4)
|
||||
|
||||
lib_list = []
|
||||
for lib in libs:
|
||||
for prefix in [prefix1, prefix2, prefix3, prefix4]:
|
||||
f = Path(prefix) / lib
|
||||
if f.is_file():
|
||||
lib_list.append(str(f))
|
||||
break
|
||||
|
||||
print("lib_list", lib_list)
|
||||
libs = "\n ;".join(lib_list)
|
||||
prefix = "/tmp/windows/"
|
||||
libs = [prefix + lib for lib in libs]
|
||||
libs = "\n ;".join(libs)
|
||||
|
||||
d = get_dict()
|
||||
d["dotnet_rid"] = "win-x64"
|
||||
|
||||
@@ -138,6 +138,8 @@ namespace SherpaOnnx
|
||||
|
||||
DecodingMethod = "greedy_search";
|
||||
MaxActivePaths = 4;
|
||||
HotwordsFile = "";
|
||||
HotwordsScore = 1.5F;
|
||||
|
||||
}
|
||||
public FeatureConfig FeatConfig;
|
||||
@@ -148,6 +150,11 @@ namespace SherpaOnnx
|
||||
public string DecodingMethod;
|
||||
|
||||
public int MaxActivePaths;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string HotwordsFile;
|
||||
|
||||
public float HotwordsScore;
|
||||
}
|
||||
|
||||
public class OfflineRecognizerResult
|
||||
|
||||
@@ -3,6 +3,75 @@
|
||||
|
||||
set -ex
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)
|
||||
echo "SCRIPT_DIR: $SCRIPT_DIR"
|
||||
echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR"
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" $SHERPA_ONNX_DIR/CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
mkdir -p /tmp/
|
||||
pushd /tmp
|
||||
|
||||
mkdir -p linux macos windows
|
||||
|
||||
if [ ! -f /tmp/linux/libsherpa-onnx-core.so ]; then
|
||||
echo "---linux x86_64---"
|
||||
cd linux
|
||||
mkdir wheel
|
||||
cd wheel
|
||||
curl -OL https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||
unzip sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||
cp -v sherpa_onnx/lib/*.so* ../
|
||||
cd ..
|
||||
rm -v libpiper_phonemize.so libpiper_phonemize.so.1.2.0
|
||||
rm -v libsherpa-onnx-fst.so
|
||||
rm -v libonnxruntime.so
|
||||
rm -v libcargs.so
|
||||
rm -rf wheel
|
||||
ls -lh
|
||||
cd ..
|
||||
fi
|
||||
|
||||
if [ ! -f /tmp/macos/libsherpa-onnx-core.dylib ]; then
|
||||
echo "---macOS x86_64---"
|
||||
cd macos
|
||||
mkdir wheel
|
||||
cd wheel
|
||||
curl -OL https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_10_14_x86_64.whl
|
||||
unzip sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_10_14_x86_64.whl
|
||||
cp -v sherpa_onnx/lib/*.dylib ../
|
||||
|
||||
cd ..
|
||||
|
||||
rm -v libcargs.dylib
|
||||
rm -v libonnxruntime.dylib
|
||||
rm -v libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
|
||||
rm -v libsherpa-onnx-fst.dylib
|
||||
rm -rf wheel
|
||||
ls -lh
|
||||
cd ..
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f /tmp/windows/libsherpa-onnx-core.dll ]; then
|
||||
echo "---windows x64---"
|
||||
cd windows
|
||||
mkdir wheel
|
||||
cd wheel
|
||||
curl -OL https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
|
||||
unzip sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
|
||||
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll ../
|
||||
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.lib ../
|
||||
cd ..
|
||||
|
||||
rm -rf wheel
|
||||
ls -lh
|
||||
cd ..
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
mkdir -p macos linux windows all
|
||||
|
||||
cp ./online.cs all
|
||||
@@ -31,3 +100,6 @@ dotnet pack -c Release -o ../packages
|
||||
popd
|
||||
|
||||
ls -lh packages
|
||||
|
||||
mkdir /tmp/packages
|
||||
cp -v packages/*.nupkg /tmp/packages
|
||||
|
||||
Reference in New Issue
Block a user