[Python] refactor speaker-identification.py #2225
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
相關 issue: #2208 #2212
由於改動有點多,所以先只改一個檔案並發個草稿 PR,看看能不能接受此改動。
如果能接受,之後將會將類似此改動套用到以下檔案
以上都是在 python-api-examples 資料夾下的檔案
這次草稿以
speaker-identification.py
為修改範例,主要邏輯基本上全部維持一樣,主要重構的方向有因為我本身不太熟這些看起來像是 C 語言(?)包裝的物件怎使用,這些物件能使用的方法除了看 example 之外很難知道
例如以下 code
我自己是期望對於這些物件,例如:
sherpa_onnx.SpeakerEmbeddingExtractor
或者sherpa_onnx.SpeakerEmbeddingManager
,都能移動到此 package 的一個類似core
的 module,而另外包一個應用層的程式碼,例如此 PR 的上半部給使用者更直觀的使用。當然為了向前兼容,使用者依然可以直接操縱這些 core 的物件來寫 code,這樣也不會影響到已經正在使用現有套件專案的人