Skip to content

Commit 15f8493

Browse files
chore(core+ui+tests): refactor vLLM plugin and UI updates, add CodeQL integration
- Introduced `qwen_asr.vllm_plugin` for vLLM model registry, improving customization. - Updated exception handling for `BaseDummyInputsBuilder` imports in `vllm_backend`. - Fixed `cnn_len` iteration issue in `transformers_backend` by switching to `.tolist()`. - Enhanced UI callbacks for safe API base URL validation and realtime session ID handling. - Added new tests for URL and session ID validation, aligning with OpenAI compatibility. - Integrated `run_codeql.ps1` into scripts and `Taskfile.yml` to enable security analysis. - Streamlined imports with `TYPE_CHECKING`, optimized logging, and removed unused `logger`. - Updated DockerHub documentation banner to use new logo.
1 parent 3311db5 commit 15f8493

17 files changed

Lines changed: 308 additions & 59 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ venv/
2323
env/
2424

2525
.idea
26+
.codeql/
2627
testbench/results/*.json

Taskfile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ tasks:
8686
cmds:
8787
- 'cmd /c ".venv\Scripts\python.exe" -m compileall -q qwen_asr testbench examples'
8888

89+
codeql:
90+
desc: Run CodeQL Python security-and-quality analysis
91+
cmds:
92+
- powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_codeql.ps1
93+
8994
deps:
9095
desc: Regenerate Linux/Python 3.13 requirements.txt from requirements.in
9196
cmds:

docs/dockerhub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p>
2-
<img src="https://github.com/Hangry-Labs/Qwen3-ASR-STT/raw/main/hangrylabs/banner.jpg" alt="Hangry Labs Qwen3-ASR-STT banner">
2+
<img src="https://github.com/Hangry-Labs/Qwen3-ASR-STT/raw/main/logo.jpg" alt="Hangry Labs Qwen3-ASR-STT banner">
33
</p>
44

55
# Hangry Labs Qwen3-ASR-STT

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Homepage = "https://github.com/hangry-labs/Qwen3-ASR-STT"
4949
Repository = "https://github.com/hangry-labs/Qwen3-ASR-STT"
5050
"Upstream Project" = "https://github.com/QwenLM/Qwen3-ASR"
5151

52+
[project.entry-points."vllm.general_plugins"]
53+
qwen_asr = "qwen_asr.vllm_plugin:register"
54+
5255
[tool.setuptools]
5356
packages = { find = { where = ["."] , include = ["qwen_asr*"] } }
5457
include-package-data = true

qwen_asr/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
qwen_asr: Qwen3-ASR package.
1818
"""
1919
from importlib.metadata import PackageNotFoundError, version
20+
from typing import TYPE_CHECKING
2021

21-
from .inference.qwen3_asr import Qwen3ASRModel
22-
from .inference.qwen3_forced_aligner import Qwen3ForcedAligner
22+
if TYPE_CHECKING:
23+
from .inference.qwen3_asr import Qwen3ASRModel
24+
from .inference.qwen3_forced_aligner import Qwen3ForcedAligner
2325

2426
from .inference.utils import parse_asr_output
2527

@@ -29,3 +31,15 @@
2931
__version__ = "0.0.0"
3032

3133
__all__ = ["Qwen3ASRModel", "Qwen3ForcedAligner", "parse_asr_output", "__version__"]
34+
35+
36+
def __getattr__(name: str):
37+
if name == "Qwen3ASRModel":
38+
from .inference.qwen3_asr import Qwen3ASRModel
39+
40+
return Qwen3ASRModel
41+
if name == "Qwen3ForcedAligner":
42+
from .inference.qwen3_forced_aligner import Qwen3ForcedAligner
43+
44+
return Qwen3ForcedAligner
45+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

qwen_asr/core/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# coding=utf-8
2+

qwen_asr/core/transformers_backend/configuration_qwen3_asr.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
from transformers.configuration_utils import PretrainedConfig
16-
from transformers.utils import logging
17-
18-
19-
logger = logging.get_logger(__name__)
2016

2117

2218
class Qwen3ASRAudioEncoderConfig(PretrainedConfig):

qwen_asr/core/transformers_backend/modeling_qwen3_asr.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def forward(
718718
hidden_states = padded_embed[padded_mask_after_cnn]
719719
cu_chunk_lens = [0]
720720
window_aftercnn = padded_mask_after_cnn.shape[-1] * (self.n_window_infer // (self.n_window * 2))
721-
for cnn_len in aftercnn_lens:
721+
for cnn_len in aftercnn_lens.tolist():
722722
cu_chunk_lens += [window_aftercnn] * (cnn_len // window_aftercnn)
723723
remainder = cnn_len % window_aftercnn
724724
if remainder != 0:
@@ -1187,6 +1187,9 @@ def forward(
11871187
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
11881188
"""
11891189

1190+
if audio_feature_lengths is None and feature_attention_mask is not None:
1191+
audio_feature_lengths = torch.sum(feature_attention_mask, dim=1)
1192+
11901193
if inputs_embeds is None:
11911194
# 1. Extract the input embeddings
11921195
inputs_embeds = self.get_input_embeddings()(input_ids)
@@ -1202,11 +1205,6 @@ def forward(
12021205
audio_mask = self.get_placeholder_mask(input_ids, inputs_embeds=inputs_embeds)
12031206
inputs_embeds = inputs_embeds.masked_scatter(audio_mask, audio_features)
12041207

1205-
if feature_attention_mask is not None:
1206-
audio_feature_lengths = torch.sum(feature_attention_mask, dim=1)
1207-
else:
1208-
audio_feature_lengths = None
1209-
12101208
if attention_mask is not None and position_ids is None:
12111209
if (
12121210
cache_position is None

qwen_asr/core/vllm_backend/qwen3_asr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
try:
108108
from vllm.multimodal.profiling import BaseDummyInputsBuilder
109-
except:
109+
except ImportError:
110110
from vllm.multimodal.processing import BaseDummyInputsBuilder
111111

112112
logger = init_logger(__name__)
@@ -994,4 +994,4 @@ def get_generation_prompt(
994994
"prompt_token_ids": prompt_token_ids,
995995
"multi_modal_data": {"audio": audio},
996996
}
997-
return cast(PromptType, prompt_dict)
997+
return cast(PromptType, prompt_dict)

qwen_asr/inference/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# coding=utf-8
2+

0 commit comments

Comments
 (0)