Explorar o código

Show how to pre-download needed files (#53)

Fangjun Kuang %!s(int64=2) %!d(string=hai) anos
pai
achega
68b37920e9

+ 8 - 2
cmake/kaldi-native-fbank.cmake

@@ -4,9 +4,15 @@ function(download_kaldi_native_fbank)
   set(kaldi_native_fbank_URL  "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.8.tar.gz")
   set(kaldi_native_fbank_HASH "SHA256=1aefda7e76456e2c5005e05fa10cdc7f91c3ffc0a7fad000a90b50e7ed18087b")
 
-  # If you don't have access to the internet, please download it to your
+  # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  # set(kaldi_native_fbank_URL  "file:///star-fj/fangjun/download/github/kaldi-native-fbank-1.8.tar.gz")
+  if(EXISTS "/star-fj/fangjun/download/github/kaldi-native-fbank-1.8.tar.gz")
+    set(kaldi_native_fbank_URL  "file:///star-fj/fangjun/download/github/kaldi-native-fbank-1.8.tar.gz")
+  elseif(EXISTS "/Users/fangjun/Downloads/kaldi-native-fbank-1.8.tar.gz")
+    set(kaldi_native_fbank_URL  "file:///Users/fangjun/Downloads/kaldi-native-fbank-1.8.tar.gz")
+  elseif(EXISTS "/tmp/kaldi-native-fbank-1.8.tar.gz")
+    set(kaldi_native_fbank_URL  "file:///tmp/kaldi-native-fbank-1.8.tar.gz")
+  endif()
 
   set(KALDI_NATIVE_FBANK_BUILD_TESTS OFF CACHE BOOL "" FORCE)
   set(KALDI_NATIVE_FBANK_BUILD_PYTHON OFF CACHE BOOL "" FORCE)

+ 8 - 2
cmake/ncnn.cmake

@@ -8,9 +8,15 @@ function(download_ncnn)
   set(ncnn_URL "https://github.com/csukuangfj/ncnn/archive/refs/tags/sherpa-0.8.tar.gz")
   set(ncnn_HASH "SHA256=f605c48986406800615d00cf14b955e95f73286eadacedb6c3371542540e1df0")
 
-  # If you don't have access to the internet, please download it to your
+  # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  # set(ncnn_URL  "file:///star-fj/fangjun/download/github/ncnn-sherpa-0.8.tar.gz")
+  if(EXISTS "/star-fj/fangjun/download/github/ncnn-sherpa-0.8.tar.gz")
+    set(ncnn_URL  "file:///star-fj/fangjun/download/github/ncnn-sherpa-0.8.tar.gz")
+  elseif(EXISTS "/Users/fangjun/Downloads/ncnn-sherpa-0.8.tar.gz")
+    set(ncnn_URL  "file:///Users/fangjun/Downloads/ncnn-sherpa-0.8.tar.gz")
+  elseif(EXISTS "/tmp/ncnn-sherpa-0.8.tar.gz")
+    set(ncnn_URL  "file:///tmp/ncnn-sherpa-0.8.tar.gz")
+  endif()
 
   FetchContent_Declare(ncnn
     URL               ${ncnn_URL}

+ 9 - 3
cmake/portaudio.cmake

@@ -4,9 +4,15 @@ function(download_portaudio)
   set(portaudio_URL  "http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz")
   set(portaudio_HASH "SHA256=47efbf42c77c19a05d22e627d42873e991ec0c1357219c0d74ce6a2948cb2def")
 
-  # If you don't have access to the internet, please download it to your
+  # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  # set(portaudio_URL  "file:///star-fj/fangjun/download/github/pa_stable_v190700_20210406.tgz")
+  if(EXISTS "/star-fj/fangjun/download/github/pa_stable_v190700_20210406.tgz")
+    set(portaudio_URL  "file:///star-fj/fangjun/download/github/pa_stable_v190700_20210406.tgz")
+  elseif(EXISTS "/Users/fangjun/Downloads/pa_stable_v190700_20210406.tgz")
+    set(portaudio_URL  "file:///Users/fangjun/Downloads/pa_stable_v190700_20210406.tgz")
+  elseif(EXISTS "/tmp/pa_stable_v190700_20210406.tgz")
+    set(portaudio_URL  "file:///tmp/pa_stable_v190700_20210406.tgz")
+  endif()
 
   if(BUILD_SHARED_LIBS)
     set(PA_BUILD_SHARED ON CACHE BOOL "" FORCE)
@@ -23,7 +29,7 @@ function(download_portaudio)
 
   FetchContent_GetProperties(portaudio)
   if(NOT portaudio_POPULATED)
-    message(STATUS "Downloading portaudio")
+    message(STATUS "Downloading portaudio from ${portaudio_URL}")
     FetchContent_Populate(portaudio)
   endif()
   message(STATUS "portaudio is downloaded to ${portaudio_SOURCE_DIR}")

+ 8 - 2
cmake/pybind11.cmake

@@ -4,9 +4,15 @@ function(download_pybind11)
   set(pybind11_URL  "https://github.com/pybind/pybind11/archive/refs/tags/v2.10.2.tar.gz")
   set(pybind11_HASH "SHA256=93bd1e625e43e03028a3ea7389bba5d3f9f2596abc074b068e70f4ef9b1314ae")
 
-  # If you don't have access to the internet, please download it to your
+  # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  # set(pybind11_URL  "file:///star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
+  if(EXISTS "/star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
+    set(pybind11_URL  "file:///star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
+  elseif(EXISTS "/Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
+    set(pybind11_URL  "file:///Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
+  elseif(EXISTS "/tmp/pybind11-2.10.2.tar.gz")
+    set(pybind11_URL  "file:///tmp/pybind11-2.10.2.tar.gz")
+  endif()
 
   FetchContent_Declare(pybind11
     URL               ${pybind11_URL}

+ 1 - 1
python-api-examples/speech-recognition-from-microphone.py

@@ -64,4 +64,4 @@ if __name__ == "__main__":
     try:
         main()
     except KeyboardInterrupt:
-        print("\nCatch Ctrl + C. Exiting")
+        print("\nCaught Ctrl + C. Exiting")