Я не могу удалить файл с помощью os.remove (), используя следующий код,
import pygame
from pygame.mixer import *
import os
from pygame import mixer
def play_music(music_file, volume):
with open(music_file, 'wb') as f:
f.write(spoken_text['AudioStream'].read())
f.close()
mixer.init()
mixer.music.load(music_file)
mixer.music.play()
#pygame.mixer.init()
while pygame.mixer.music.get_busy():
pygame.time.Clock().tick(10)
else:
os.remove(music_file)
music_file = "C:/CBot/output.mp3"
volume = 0.4
play_music(music_file, volume)
Отображается следующая ошибка:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:/CBot/output.mp3'