From dec1c875b2fcf0161755b93717d3eac856c6d15d Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 31 一月 2024 22:40:19 +0800
Subject: [PATCH] Funasr1.0 bugfix, audio sample input for the vad model (#1333)
---
funasr/download/file.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/funasr/download/file.py b/funasr/download/file.py
index d93f24c..da4958a 100644
--- a/funasr/download/file.py
+++ b/funasr/download/file.py
@@ -8,7 +8,23 @@
from typing import Generator, Union
import requests
+from urllib.parse import urlparse
+def download_from_url(url):
+ result = urlparse(url)
+ file_path = None
+ 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)
+ file_path = os.path.join(work_dir, os.path.basename(url))
+ with open(file_path, 'wb') as fb:
+ fb.write(data)
+ assert file_path is not None, f"failed to download: {url}"
+ return file_path
class Storage(metaclass=ABCMeta):
"""Abstract class of storage.
--
Gitblit v1.9.1