MCPcopy Create free account
hub / github.com/modelscope/FunASR / write

Method write

funasr/models/campplus/utils.py:359–375  ·  view source on GitHub ↗

Write data to a given ``filepath`` with 'wb' mode. Note: ``write`` will create a directory if the directory of ``filepath`` does not exist. Args: obj (bytes): Data to be written. filepath (str or Path): Path to write data.

(self, obj: bytes, filepath: Union[str, Path])

Source from the content-addressed store, hash-verified

357 return value_buf
358
359 def write(self, obj: bytes, filepath: Union[str, Path]) -> None:
360 """Write data to a given ``filepath`` with 'wb' mode.
361
362 Note:
363 ``write`` will create a directory if the directory of ``filepath``
364 does not exist.
365
366 Args:
367 obj (bytes): Data to be written.
368 filepath (str or Path): Path to write data.
369 """
370 dirname = os.path.dirname(filepath)
371 if dirname and not os.path.exists(dirname):
372 os.makedirs(dirname, exist_ok=True)
373
374 with open(filepath, "wb") as f:
375 f.write(obj)
376
377 def write_text(self, obj: str, filepath: Union[str, Path], encoding: str = "utf-8") -> None:
378 """Write data to a given ``filepath`` with 'w' mode.

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected