mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-24 20:19:22 +01:00
fix bug:modify function generate_scp_from_url
对于多通道url音频,目前maas-lib解析出来的bytes 每个通道的数据都混到了一起,因此做出修改:用户输入url音频,maas-lib负责下载到本地,然后把本地音频路径传给funasr,然后由funasr做音频解析
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11948914
* modify function generate_scp_from_url
This commit is contained in:
@@ -211,13 +211,19 @@ def generate_scp_from_url(url: str, key: str = None):
|
||||
wav_scp_path = url
|
||||
return wav_scp_path, raw_inputs
|
||||
# for wav url, download bytes data
|
||||
result = urlparse(url)
|
||||
if result.scheme is not None and len(result.scheme) > 0:
|
||||
storage = HTTPStorage()
|
||||
# bytes
|
||||
wav_scp_path = storage.read(url)
|
||||
|
||||
return wav_scp_path, raw_inputs
|
||||
if url.startswith('http'):
|
||||
result = urlparse(url)
|
||||
if result.scheme is not None and len(result.scheme) > 0:
|
||||
storage = HTTPStorage()
|
||||
# bytes
|
||||
data = storage.read(url)
|
||||
work_dir = tempfile.TemporaryDirectory().name
|
||||
if not os.path.exists(work_dir):
|
||||
os.makedirs(work_dir)
|
||||
wav_path = os.path.join(work_dir, os.path.basename(url))
|
||||
with open(wav_path, 'wb') as fb:
|
||||
fb.write(data)
|
||||
return wav_path, raw_inputs
|
||||
|
||||
return wav_scp_path, raw_inputs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user