Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __getitem__(self, i) -> Dict[str, torch.Tensor]:
ctc_ids = ctc_tokens['input_ids'][0]
ctc_ids_len = ctc_tokens['attention_mask'].sum().item()
ret = {
'wav': msg['wav'],
'input_ids': input_ids,
'attention_mask': attention_mask,
'mel': mel,
Expand Down
4 changes: 2 additions & 2 deletions recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def main():
text = tokenizer.batch_decode(generated_ids,
skip_special_tokens=True)
print(text)
for t in text:
for wav, t in zip(item['wav'], text):
t = t.replace('\n', ' ')
fid.write(t + '\n')
fid.write(wav + ' ' + t + '\n')
sys.stdout.flush()
fid.close()

Expand Down
5 changes: 4 additions & 1 deletion speech_llm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2025 Binbin Zhang(binbzha@qq.com)

import math
from typing import Optional
from typing import List, Optional
from dataclasses import dataclass, field

import safetensors
Expand Down Expand Up @@ -148,6 +148,7 @@ def get_speech_embeddings(self, mel, mel_len):
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
def forward(
self,
wav: List[str] = None,
input_ids: torch.LongTensor = None,
attention_mask: Optional[torch.Tensor] = None,
labels: Optional[torch.LongTensor] = None,
Expand Down Expand Up @@ -181,6 +182,7 @@ def forward(
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
def generate(
self,
wav: List[str] = None,
input_ids: torch.LongTensor = None,
attention_mask: Optional[torch.Tensor] = None,
mel: torch.LongTensor = None,
Expand All @@ -207,6 +209,7 @@ def generate(
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
def decode_ctc(
self,
wav: List[str] = None,
input_ids: torch.LongTensor = None,
attention_mask: Optional[torch.Tensor] = None,
mel: torch.LongTensor = None,
Expand Down