Не видит файл. Есть идеи?

Рейтинг: 0Ответов: 0Опубликовано: 04.03.2023
from pydub import AudioSegment

pydub.AudioSegment.converter = os.getcwd()+ "\\ffmpeg.exe"                    
pydub.AudioSegment.ffprobe   = os.getcwd()+ "\\ffprobe.exe"
# Load the audio files
audio = AudioSegment.from_file("C:\\Users\\Pumpetee\\Desktop\\Private_new\\Programming\\ChatGPT\\New\\audio.wav")
speech = AudioSegment.from_file("C:\\Users\\Pumpetee\\Desktop\\Private_new\\Programming\\ChatGPT\\New\\speech4.wav")


##Calculate the ratio of speech duration to audio duration
ratio = len(audio) / len(speech)

#Apply the speed change to the speech file
if ratio < 1:
    speech = speech.strip_silence(silence_len=100, silence_thresh=-35) # remove silence before speeding up
    speech = speech.speedup(playback_speed=ratio)

#Truncate the speech file to match the duration of the audio file
speech = speech[:len(audio)]

#Export the modified speech file
speech.export("speech4_modified.wav", format="wav")
C:\Users\Pumpetee\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Users\Pumpetee\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "C:\Users\Pumpetee\Desktop\Private_new\Programming\ChatGPT\New\cut_v2.py", line 5, in <module>
    speech = AudioSegment.from_file("C:\\Users\\Pumpetee\\Desktop\\Private_new\\Programming\\ChatGPT\\New\\speech4.wav")
  File "C:\Users\Pumpetee\AppData\Roaming\Python\Python39\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\Pumpetee\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Program Files\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Не удается найти указанный файл

Дичь пишет полную. Файл лежит. Указан абсолютный путь. Предварительно файл бы сгенерирован gtts библиотекой. Открывается в проигрывателе.

введите сюда описание изображения

Ответы

Ответов пока нет.