[Python] refactor speaker-identification.py#2225
Draft
gbaian10 wants to merge 2 commits intok2-fsa:masterfrom
Draft
[Python] refactor speaker-identification.py#2225gbaian10 wants to merge 2 commits intok2-fsa:masterfrom
gbaian10 wants to merge 2 commits intok2-fsa:masterfrom
Conversation
csukuangfj
reviewed
May 19, 2025
| @@ -1,5 +1,3 @@ | |||
| #!/usr/bin/env python3 | |||
Collaborator
There was a problem hiding this comment.
Please don't remove this line.
| # %% | ||
| # The following code is required for command line interface. | ||
| # If you only need the packaged functions, you can use only the code above | ||
| import argparse |
Collaborator
There was a problem hiding this comment.
Please put all imports at the beginning.
Author
There was a problem hiding this comment.
The code has been moved to the top.
Author
|
It has been revised according to the requirements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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,這樣也不會影響到已經正在使用現有套件專案的人