MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / any_to_mp3

Function any_to_mp3

apps/common/utils/common.py:243–255  ·  view source on GitHub ↗

把任意格式转成mp3文件

(any_path, mp3_path)

Source from the content-addressed store, hash-verified

241
242
243def any_to_mp3(any_path, mp3_path):
244 """
245 把任意格式转成mp3文件
246 """
247 if any_path.endswith(".mp3"):
248 shutil.copy2(any_path, mp3_path)
249 return
250 if any_path.endswith(".sil") or any_path.endswith(".silk") or any_path.endswith(".slk"):
251 sil_to_wav(any_path, any_path)
252 any_path = mp3_path
253 audio = AudioSegment.from_file(any_path)
254 audio = audio.set_frame_rate(16000)
255 audio.export(mp3_path, format="mp3")
256
257
258def sil_to_wav(silk_path, wav_path, rate: int = 24000):

Callers 1

process_audio_itemMethod · 0.90

Calls 2

sil_to_wavFunction · 0.85
exportMethod · 0.45

Tested by

no test coverage detected