Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
“weifeng2333” committed Oct 15, 2024
1 parent 3370f02 commit 78af9a0
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions bk_asr/JianYingASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import json
import logging
import os
import subprocess
import time
from typing import Dict, Tuple, Literal
from typing import Dict, Tuple

# import ffmpeg
import requests

from .ASRData import ASRDataSeg
Expand Down Expand Up @@ -91,12 +89,33 @@ def _make_segments(self, resp_data: dict) -> list[ASRDataSeg]:
@staticmethod
def _generate_sign_parameters(url: str, pf: str = '4', appvr: str = '4.0.0', tdid: str = '3943278516897751') -> \
Tuple[str, str]:
"""Generate signature and timestamp"""
"""Generate signature and timestamp via an HTTP request"""
current_time = str(int(time.time()))
sign_str = f"9e2c|{url[-7:]}|{pf}|{appvr}|{current_time}|{tdid}|11ac"
sign = hashlib.md5(sign_str.encode()).hexdigest()
data = {
'url': url,
'current_time': current_time,
'pf': pf,
'appvr': appvr,
'tdid': tdid
}
# Replace with your actual endpoint URL
get_sign_url = 'https://asrtools-update.bkfeng.top/sign'
try:
response = requests.post(get_sign_url, json=data)
response.raise_for_status()
response_data = response.json()
sign = response_data.get('sign')
if not sign:
raise ValueError("No 'sign' in response")
except requests.exceptions.RequestException as e:
raise SystemExit(f"HTTP Request failed: {e}")
except ValueError as ve:
raise SystemExit(f"Invalid response: {ve}")
print(f"Generated sign: {sign}")
return sign.lower(), current_time



def _build_headers(self, device_time: str, sign: str) -> Dict[str, str]:
"""Build headers for requests"""
return {
Expand Down

0 comments on commit 78af9a0

Please sign in to comment.