
Common Voice 是 Mozilla 發起的一個開源專案,目的是建立一個大型、公開、自由可用的語音資料庫,讓任何人(尤其是研究人員、開發者、公司)都可以用來訓練語音辨識、語音合成(TTS)等人工智慧應用。
很幸運的, Common Voice也將原始碼提供給大家使用, 在 🔍 https://github.com/common-voice/common-voice/tree/main 可以找到。
好了, 讓我們進入正題, 在啟動Common Voice的過程中也不是這麼的順利, 因此期望透過我們的分享, 讓需要的朋友可以省去踩坑的過程, 您的訂閱與愛心都是我們分享的動力, 真心期待我們可以一起學習及成長。
🚀 首先讓我們啟動
docker compose up web
一開始啟動會連不到db, 這部份需要等待一段時間後再啟動web, 讓它重新連線。
問題一: 我的權限不夠高嗎?
咦! 啟動時竟然發生這問題…, 難道我沒有權限或權限不夠?
web | Failed to access /.cache/Cypress:
web |
web | EACCES: permission denied, mkdir '/.cache'
主要是因為我們在docker/Dockerfile有設定權限的參數:
ARG UID=10001
ARG GID=10001
但我們啟動時, 根據文件的建議, 設定為主機的帳號集群組:
web:
build:
context: .
dockerfile: docker/Dockerfile
container_name: web
user: '${UID:-10001}:${GID:-10001}'
這樣一來存取 /.cache 當然會出問題呀, 那怎麼辦呢? 我們可以更改一下位置, 在compose的環境變數這樣做
environment:
- DOTENV_CONFIG_PATH=/code/.env-local-docker
- CYPRESS_CACHE_FOLDER=/code/.cache/Cypress
問題二: 為什麼Cannot read properties of null (reading 'includes')
詳細的錯誤我們貼來這邊一起看看。
web | [BE] unhandled promise rejection TypeError: Cannot read properties of null (reading 'includes')
web | [BE] at resolveWellKnownUri (/code/node_modules/openid-client/lib/issuer.js:179:23)
web | [BE] at Function.discover (/code/node_modules/openid-client/lib/issuer.js:142:26)
web | [BE] at setupAuthRouter (/code/server/src/auth-router.ts:36:34)
web | [BE] at Server.setupApp (/code/server/src/server.ts:125:36)
web | [BE] at runServer (/code/server/src/main.ts:27:18)
web | [BE] at Object.<anonymous> (/code/server/src/main.ts:34:1)
web | [BE] at Module._compile (node:internal/modules/cjs/loader:1364:14)
web | [BE] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
web | [BE] at Module.load (node:internal/modules/cjs/loader:1203:32)
web | [BE] at Function.Module._load (node:internal/modules/cjs/loader:1019:12)
web | [BE] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
web | [BE] at node:internal/main/run_main_module:28:49
仔細追查後發現到關鍵的 「openid-client」這很有可能跟認證與授權有關, 因此讓我們再詳細的翻閱文件看看究竟有什麼貓膩! 幸好皇天不負苦心人, 讓我們在 https://github.com/common-voice/common-voice/blob/main/docs/DEVELOPMENT.md#authentication 這裡找到了Auth相關的配置。
要怎麼進行這個部份呢?
- Create an Auth0 account.
- Click "Applications" from the dashboard. Create a new one, or use the default application.
- On "Applications" still, next to your application, click the "three dots" icon, then Settings.
- Add
http://localhost:9000/callback
to the "Allowed Callback URLs" list. - Copy the Auth0 application settings into your configuration file. These are found in the same Settings tab as the "Allowed Callback URLs".
我們只要照著上述的步驟就能夠得到我們配置所需的值。
讓我們在 .env-local-docker
配置以下的設定吧!
CV_AUTH0_DOMAIN="<domain_here>"
CV_AUTH0_CLIENT_ID="<client_id_here>"
CV_AUTH0_CLIENT_SECRET="<client_secret_here>"
問題三: 順利啟動了, 但卻一直導到 404 頁面
我們可以看到 http://localhost:9002/en/404 會一直不斷的請求 /translations。

這是因為我們的語言缺失, 因此我們需要再刷一次這樣的腳本, 讓語言資訊同步到快取伺服器。
docker exec -it redis redis-cli FLUSHALL
接著我們重新再進入到 http://localhost:9000 就可以看到頁面順利的進入了。

結語
以上是我們在架設Common Voice時遇到的一些狀況, 我們希望透過分享, 讓大家都能夠避開這些坑, 也希望這篇文章真的有幫助到遇到困難的你們, 讓我們共同突破難關, 讓軟體品質越來越好。