MCPcopy Create free account
hub / github.com/modelscope/modelscope / generate_text_from_url

Function generate_text_from_url

modelscope/utils/audio/audio_utils.py:236–262  ·  view source on GitHub ↗
(url: str)

Source from the content-addressed store, hash-verified

234
235
236def generate_text_from_url(url: str):
237 text_file_path = None
238 raw_inputs = None
239 # for text str input
240 if not os.path.exists(url) and not url.startswith('http'):
241 raw_inputs = url
242 return text_file_path, raw_inputs
243
244 # for local txt inputs
245 if os.path.exists(url) and (url.lower().endswith('.txt')
246 or url.lower().endswith('.scp')):
247 text_file_path = url
248 return text_file_path, raw_inputs
249 # for url, download and generate txt
250 result = urlparse(url)
251 if result.scheme is not None and len(result.scheme) > 0:
252 storage = HTTPStorage()
253 data = storage.read(url)
254 work_dir = tempfile.TemporaryDirectory().name
255 if not os.path.exists(work_dir):
256 os.makedirs(work_dir)
257 text_file_path = os.path.join(work_dir, os.path.basename(url))
258 with open(text_file_path, 'wb') as fp:
259 fp.write(data)
260 return text_file_path, raw_inputs
261
262 return text_file_path, raw_inputs
263
264
265def generate_scp_for_sv(url: str, key: str = None):

Callers

nothing calls this directly

Calls 4

readMethod · 0.95
HTTPStorageClass · 0.90
existsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…