MCPcopy
hub / github.com/1Panel-dev/MaxKB / any_to_amr

Function any_to_amr

apps/common/utils/common.py:228–240  ·  view source on GitHub ↗

把任意格式转成amr文件

(any_path, amr_path)

Source from the content-addressed store, hash-verified

226
227
228def any_to_amr(any_path, amr_path):
229 """
230 把任意格式转成amr文件
231 """
232 if any_path.endswith(".amr"):
233 shutil.copy2(any_path, amr_path)
234 return
235 if any_path.endswith(".sil") or any_path.endswith(".silk") or any_path.endswith(".slk"):
236 raise NotImplementedError("Not support file type: {}".format(any_path))
237 audio = AudioSegment.from_file(any_path)
238 audio = audio.set_frame_rate(8000) # only support 8000
239 audio.export(amr_path, format="amr")
240 return audio.duration_seconds * 1000
241
242
243def any_to_mp3(any_path, mp3_path):

Callers

nothing calls this directly

Calls 1

exportMethod · 0.45

Tested by

no test coverage detected