import os
import logging
import openai
import sys
import lxml.etree as ET
import librosa
import noisereduce as nr
import numpy as np
import torch
import asyncio
import soundfile as sf
from torchaudio.transforms import MelSpectrogram
from transformers import Wav2Vec2Tokenizer, Wav2Vec2ForCTC, HubertForCTC
from music21 import stream, note, converter, instrument
from scipy import signal
from pydub import AudioSegment
from pydub.playback import play
 
# Настройка логирования
logging.basicConfig(level=logging.DEBUG)  # Переключаем на DEBUG для детального логирования
 
# Загрузка ключа API из переменных среды
openai.api_key = os.environ.get('OPENAI_API_KEY')
 
def initialize_openai():
    """
    Проверка подключения к OpenAI с использование ключа API.
    """
    if openai.api_key:
        try:
            response = openai.Completion.create(model="gpt-4", prompt="Hello, world!", max_tokens=5)
            logging.info("Подключение к OpenAI API успешно")
        except openai.error.AuthenticationError:
            logging.error("Ошибка аутентификации: Неверный ключ OpenAI API")
        except Exception as e:
            logging.error(f"Ошибка при подключении к OpenAI API: {e}")
    else:
        logging.warning("Ключ OpenAI API не найден. API будет проигнорирован")
        # НЕ поднимаем ValueError здесь
 
initialize_openai()
 
async def preprocess_audio(file_path):
    """
    Загрузка и предварительная обработка аудио (нормализация, шумоподавление).
    """
    try:
        logging.info(f"Loading and preprocessing audio from {file_path}")
        y, sr = librosa.load(file_path, sr=None)
        y = librosa.util.normalize(y)
        y = nr.reduce_noise(y=y, sr=sr)
        y = np.asfortranarray(y)
        logging.info("Audio preprocessing completed")
        return y, sr
    except Exception as e:
        logging.error(f"Error preprocessing audio: {e}")
        return None, None
 
async def extract_features(y, sr):
    """
    Извлечение мел-спектрограммы из аудио.
    """
    try:
        logging.info("Extracting features")
        mel_spec = MelSpectrogram()(torch.tensor(y).unsqueeze(0))
        logging.info("Feature extraction completed")
        return mel_spec
    except Exception as e:
        logging.error(f"Error extracting features: {e}")
        return None
 
def save_musicxml(score, output_path):
    """
    Сохранение партитуры в формате MusicXML.
    """
    try:
        logging.info(f"Saving MusicXML file to {output_path}")
        tree = ET.ElementTree(score)
        tree.write(output_path, encoding='UTF-8', xml_declaration=True, pretty_print=True)
        logging.info(f"MusicXML file saved successfully: {output_path}")
    except Exception as e:
        logging.error(f"Error saving MusicXML file: {e}")
 
def analyze_audio(y, sr):
    """
    Анализ аудио файла для определения темпа и тактов.
    """
    try:
        logging.info("Analyzing audio")
        tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
        logging.info(f"Audio analysis completed: tempo={tempo}, beat_frames={beat_frames}")
    except Exception as e:
        logging.error(f"Error analyzing audio: {e}")
 
def generate_text_descriptions(y, sr):
    """
    Генерация текстовых описаний аудио.
    """
    try:
        logging.info("Generating text descriptions")
        description = f"Audio has a sample rate of {sr} and length of {len(y)} samples."
        logging.info(f"Text descriptions generated: {description}")
    except Exception as e:
        logging.error(f"Error generating text descriptions: {e}")
 
def visualize_score(score, output_image_path):
    """
    Визуализация партитуры и сохранение изображения.
    """
    try:
        logging.info("Visualizing score")
        tree = ET.ElementTree(score)
        tree.write(output_image_path, encoding='UTF-8', xml_declaration=True, pretty_print=True)
        logging.info(f"Score visualization completed: {output_image_path}")
    except Exception as e:
        logging.error(f"Error visualizing score: {e}")
 
def transformer_features_wav2vec2(y, sr):
    """
    Извлечение признаков и транскрипция аудио с использованием Wav2Vec2.
    """
    try:
        tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h")
        model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
        input_values = tokenizer(y.tolist(), return_tensors="pt", padding=True).input_values
        logits = model(input_values).logits
        predicted_ids = torch.argmax(logits, dim=-1)
        transcription = tokenizer.batch_decode(predicted_ids)[0]
        logging.info(f"Transcription: {transcription}")
        return transcription
    except Exception as e:
        logging.error(f"Error extracting transformer features with Wav2Vec2: {e}")
        return None
 
async def process_pipeline(file_path, output_path, output_image_path):
    """
    Основной конвейер обработки аудио: включает предварительную обработку, извлечение признаков,
    транскрипцию, создание MusicXML, анализ и визуализацию.
    """
    try:
        logging.info("Starting audio processing pipeline")
 
        # Предварительная обработка аудио
        y, sr = await preprocess_audio(file_path)
        if not y or not sr:
            logging.error("Failed to preprocess audio")
            return
 
        # Извлечение признаков
        features = await extract_features(y, sr)
        if not features:
            logging.error("Failed to extract features")
            return
 
        # Транскрипция используя Wav2Vec2
        transcription = transformer_features_wav2vec2(y, sr)
        if not transcription:
            logging.error("Failed to transcribe audio")
            return
 
        # Создание простого XML-документа
        logging.info("Creating simple MusicXML document")
        score = ET.Element("score-partwise", version="3.1")
        part = ET.SubElement(score, "part", id="P1")
        measure = ET.SubElement(part, "measure", number="1")
        note_elem = ET.SubElement(measure, "note")
        pitch_elem = ET.SubElement(note_elem, "pitch")
        ET.SubElement(pitch_elem, "step").text = "C"
        ET.SubElement(pitch_elem, "octave").text = "4"
        ET.SubElement(note_elem, "duration").text = "1"
        ET.SubElement(note_elem, "type").text = "quarter"
 
        # Сохранение MusicXML файла
        save_musicxml(score, output_path)
 
        # Анализ аудио
        analyze_audio(y, sr)
 
        # Генерация текстовых описаний
        generate_text_descriptions(y, sr)
 
        # Визуализация партитуры
        visualize_score(score, output_image_path)
 
    except Exception as e:
        logging.error(f"Error in audio processing pipeline: {e}")
 
if __name__ == "__main__":
    file_path = r"C:\Users\ARTYOM\Documents\Python\Bring_it_up.mp3"
    output_path = r"C:\Users\ARTYOM\Documents\Python\Bring_it_up.musicxml"
    output_image_path = r"C:\Users\ARTYOM\Documents\Python\Bring_it_up.png"
 
    try:
        loop = asyncio.get_event_loop()
        loop.run_until_complete(process_pipeline(file_path, output_path, output_image_path))
    except Exception as e:
        logging.error(f"Failed to run audio processing pipeline: {e}")

ОШИБКА:

C:\Users\ARTYOM>python C:\Users\ARTYOM\Desktop\audio_processing.py
WARNING:root:Ключ OpenAI API не найден. API будет проигнорирован
DEBUG:asyncio:Using proactor: IocpProactor
INFO:root:Starting audio processing pipeline
INFO:root:Loading and preprocessing audio from C:\Users\ARTYOM\Documents\Python\Bring_it_up.mp3
DEBUG:numba.core.byteflow:bytecode dump:
>          0    NOP(arg=None, lineno=1039)
           2    LOAD_FAST(arg=0, lineno=1042)
           4    LOAD_CONST(arg=1, lineno=1042)
           6    BINARY_SUBSCR(arg=None, lineno=1042)
           8    LOAD_FAST(arg=0, lineno=1042)
          10    LOAD_CONST(arg=2, lineno=1042)
          12    BINARY_SUBSCR(arg=None, lineno=1042)
          14    COMPARE_OP(arg=4, lineno=1042)
          16    LOAD_FAST(arg=0, lineno=1042)
          18    LOAD_CONST(arg=1, lineno=1042)
          20    BINARY_SUBSCR(arg=None, lineno=1042)
          22    LOAD_FAST(arg=0, lineno=1042)
          24    LOAD_CONST(arg=3, lineno=1042)
          26    BINARY_SUBSCR(arg=None, lineno=1042)
          28    COMPARE_OP(arg=5, lineno=1042)
          30    BINARY_AND(arg=None, lineno=1042)
          32    RETURN_VALUE(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:pending: deque([State(pc_initial=0 nstack_initial=0)])
DEBUG:numba.core.byteflow:stack: []
DEBUG:numba.core.byteflow:state.pc_initial: State(pc_initial=0 nstack_initial=0)
DEBUG:numba.core.byteflow:dispatch pc=0, inst=NOP(arg=None, lineno=1039)
DEBUG:numba.core.byteflow:stack []
DEBUG:numba.core.byteflow:dispatch pc=2, inst=LOAD_FAST(arg=0, lineno=1042)
DEBUG:numba.core.byteflow:stack []
DEBUG:numba.core.byteflow:dispatch pc=4, inst=LOAD_CONST(arg=1, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$x2.0']
DEBUG:numba.core.byteflow:dispatch pc=6, inst=BINARY_SUBSCR(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$x2.0', '$const4.1']
DEBUG:numba.core.byteflow:dispatch pc=8, inst=LOAD_FAST(arg=0, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2']
DEBUG:numba.core.byteflow:dispatch pc=10, inst=LOAD_CONST(arg=2, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$x8.3']
DEBUG:numba.core.byteflow:dispatch pc=12, inst=BINARY_SUBSCR(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$x8.3', '$const10.4']
DEBUG:numba.core.byteflow:dispatch pc=14, inst=COMPARE_OP(arg=4, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$12binary_subscr.5']
DEBUG:numba.core.byteflow:dispatch pc=16, inst=LOAD_FAST(arg=0, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6']
DEBUG:numba.core.byteflow:dispatch pc=18, inst=LOAD_CONST(arg=1, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$x16.7']
DEBUG:numba.core.byteflow:dispatch pc=20, inst=BINARY_SUBSCR(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$x16.7', '$const18.8']
DEBUG:numba.core.byteflow:dispatch pc=22, inst=LOAD_FAST(arg=0, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9']
DEBUG:numba.core.byteflow:dispatch pc=24, inst=LOAD_CONST(arg=3, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$x22.10']
DEBUG:numba.core.byteflow:dispatch pc=26, inst=BINARY_SUBSCR(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$x22.10', '$const24.11']
DEBUG:numba.core.byteflow:dispatch pc=28, inst=COMPARE_OP(arg=5, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$26binary_subscr.12']
DEBUG:numba.core.byteflow:dispatch pc=30, inst=BINARY_AND(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$28compare_op.13']
DEBUG:numba.core.byteflow:dispatch pc=32, inst=RETURN_VALUE(arg=None, lineno=1042)
DEBUG:numba.core.byteflow:stack ['$30binary_and.14']
DEBUG:numba.core.byteflow:end state. edges=[]
DEBUG:numba.core.byteflow:-------------------------Prune PHIs-------------------------
DEBUG:numba.core.byteflow:Used_phis: defaultdict(<class 'set'>, {State(pc_initial=0 nstack_initial=0): set()})
DEBUG:numba.core.byteflow:defmap: {}
DEBUG:numba.core.byteflow:phismap: defaultdict(<class 'set'>, {})
DEBUG:numba.core.byteflow:changing phismap: defaultdict(<class 'set'>, {})
DEBUG:numba.core.byteflow:keep phismap: {}
DEBUG:numba.core.byteflow:new_out: defaultdict(<class 'dict'>, {})
DEBUG:numba.core.byteflow:----------------------DONE Prune PHIs-----------------------
DEBUG:numba.core.byteflow:block_infos State(pc_initial=0 nstack_initial=0):
AdaptBlockInfo(insts=((0, {}), (2, {'res': '$x2.0'}), (4, {'res': '$const4.1'}), (6, {'index': '$const4.1', 'target': '$x2.0', 'res': '$6binary_subscr.2'}), (8, {'res': '$x8.3'}), (10, {'res': '$const10.4'}), (12, {'index': '$const10.4', 'target': '$x8.3', 'res': '$12binary_subscr.5'}), (14, {'lhs': '$6binary_subscr.2', 'rhs': '$12binary_subscr.5', 'res': '$14compare_op.6'}), (16, {'res': '$x16.7'}), (18, {'res': '$const18.8'}), (20, {'index': '$const18.8', 'target': '$x16.7', 'res': '$20binary_subscr.9'}), (22, {'res': '$x22.10'}), (24, {'res': '$const24.11'}), (26, {'index': '$const24.11', 'target': '$x22.10', 'res': '$26binary_subscr.12'}), (28, {'lhs': '$20binary_subscr.9', 'rhs': '$26binary_subscr.12', 'res': '$28compare_op.13'}), (30, {'lhs': '$14compare_op.6', 'rhs': '$28compare_op.13', 'res': '$30binary_and.14'}), (32, {'retval': '$30binary_and.14', 'castval': '$32return_value.15'})), outgoing_phis={}, blockstack=(), active_try_block=None, outgoing_edgepushed={})
DEBUG:numba.core.interpreter:label 0:
    x = arg(0, name=x)                       ['x']
    $const4.1 = const(int, 0)                ['$const4.1']
    $6binary_subscr.2 = getitem(value=x, index=$const4.1, fn=<built-in function getitem>) ['$6binary_subscr.2', '$const4.1', 'x']
    $const10.4 = const(int, -1)              ['$const10.4']
    $12binary_subscr.5 = getitem(value=x, index=$const10.4, fn=<built-in function getitem>) ['$12binary_subscr.5', '$const10.4', 'x']
    $14compare_op.6 = $6binary_subscr.2 > $12binary_subscr.5 ['$12binary_subscr.5', '$14compare_op.6', '$6binary_subscr.2']
    $const18.8 = const(int, 0)               ['$const18.8']
    $20binary_subscr.9 = getitem(value=x, index=$const18.8, fn=<built-in function getitem>) ['$20binary_subscr.9', '$const18.8', 'x']
    $const24.11 = const(int, 1)              ['$const24.11']
    $26binary_subscr.12 = getitem(value=x, index=$const24.11, fn=<built-in function getitem>) ['$26binary_subscr.12', '$const24.11', 'x']
    $28compare_op.13 = $20binary_subscr.9 >= $26binary_subscr.12 ['$20binary_subscr.9', '$26binary_subscr.12', '$28compare_op.13']
    $30binary_and.14 = $14compare_op.6 & $28compare_op.13 ['$14compare_op.6', '$28compare_op.13', '$30binary_and.14']
    $32return_value.15 = cast(value=$30binary_and.14) ['$30binary_and.14', '$32return_value.15']
    return $32return_value.15                ['$32return_value.15']
 
DEBUG:numba.core.byteflow:bytecode dump:
>          0    NOP(arg=None, lineno=1045)
           2    LOAD_FAST(arg=0, lineno=1048)
           4    LOAD_CONST(arg=1, lineno=1048)
           6    BINARY_SUBSCR(arg=None, lineno=1048)
           8    LOAD_FAST(arg=0, lineno=1048)
          10    LOAD_CONST(arg=2, lineno=1048)
          12    BINARY_SUBSCR(arg=None, lineno=1048)
          14    COMPARE_OP(arg=0, lineno=1048)
          16    LOAD_FAST(arg=0, lineno=1048)
          18    LOAD_CONST(arg=1, lineno=1048)
          20    BINARY_SUBSCR(arg=None, lineno=1048)
          22    LOAD_FAST(arg=0, lineno=1048)
          24    LOAD_CONST(arg=3, lineno=1048)
          26    BINARY_SUBSCR(arg=None, lineno=1048)
          28    COMPARE_OP(arg=1, lineno=1048)
          30    BINARY_AND(arg=None, lineno=1048)
          32    RETURN_VALUE(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:pending: deque([State(pc_initial=0 nstack_initial=0)])
DEBUG:numba.core.byteflow:stack: []
DEBUG:numba.core.byteflow:state.pc_initial: State(pc_initial=0 nstack_initial=0)
DEBUG:numba.core.byteflow:dispatch pc=0, inst=NOP(arg=None, lineno=1045)
DEBUG:numba.core.byteflow:stack []
DEBUG:numba.core.byteflow:dispatch pc=2, inst=LOAD_FAST(arg=0, lineno=1048)
DEBUG:numba.core.byteflow:stack []
DEBUG:numba.core.byteflow:dispatch pc=4, inst=LOAD_CONST(arg=1, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$x2.0']
DEBUG:numba.core.byteflow:dispatch pc=6, inst=BINARY_SUBSCR(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$x2.0', '$const4.1']
DEBUG:numba.core.byteflow:dispatch pc=8, inst=LOAD_FAST(arg=0, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2']
DEBUG:numba.core.byteflow:dispatch pc=10, inst=LOAD_CONST(arg=2, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$x8.3']
DEBUG:numba.core.byteflow:dispatch pc=12, inst=BINARY_SUBSCR(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$x8.3', '$const10.4']
DEBUG:numba.core.byteflow:dispatch pc=14, inst=COMPARE_OP(arg=0, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$6binary_subscr.2', '$12binary_subscr.5']
DEBUG:numba.core.byteflow:dispatch pc=16, inst=LOAD_FAST(arg=0, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6']
DEBUG:numba.core.byteflow:dispatch pc=18, inst=LOAD_CONST(arg=1, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$x16.7']
DEBUG:numba.core.byteflow:dispatch pc=20, inst=BINARY_SUBSCR(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$x16.7', '$const18.8']
DEBUG:numba.core.byteflow:dispatch pc=22, inst=LOAD_FAST(arg=0, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9']
DEBUG:numba.core.byteflow:dispatch pc=24, inst=LOAD_CONST(arg=3, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$x22.10']
DEBUG:numba.core.byteflow:dispatch pc=26, inst=BINARY_SUBSCR(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$x22.10', '$const24.11']
DEBUG:numba.core.byteflow:dispatch pc=28, inst=COMPARE_OP(arg=1, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$20binary_subscr.9', '$26binary_subscr.12']
DEBUG:numba.core.byteflow:dispatch pc=30, inst=BINARY_AND(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$14compare_op.6', '$28compare_op.13']
DEBUG:numba.core.byteflow:dispatch pc=32, inst=RETURN_VALUE(arg=None, lineno=1048)
DEBUG:numba.core.byteflow:stack ['$30binary_and.14']
DEBUG:numba.core.byteflow:end state. edges=[]
DEBUG:numba.core.byteflow:-------------------------Prune PHIs-------------------------
DEBUG:numba.core.byteflow:Used_phis: defaultdict(<class 'set'>, {State(pc_initial=0 nstack_initial=0): set()})
DEBUG:numba.core.byteflow:defmap: {}
DEBUG:numba.core.byteflow:phismap: defaultdict(<class 'set'>, {})
DEBUG:numba.core.byteflow:changing phismap: defaultdict(<class 'set'>, {})
DEBUG:numba.core.byteflow:keep phismap: {}
DEBUG:numba.core.byteflow:new_out: defaultdict(<class 'dict'>, {})
DEBUG:numba.core.byteflow:----------------------DONE Prune PHIs-----------------------
DEBUG:numba.core.byteflow:block_infos State(pc_initial=0 nstack_initial=0):
AdaptBlockInfo(insts=((0, {}), (2, {'res': '$x2.0'}), (4, {'res': '$const4.1'}), (6, {'index': '$const4.1', 'target': '$x2.0', 'res': '$6binary_subscr.2'}), (8, {'res': '$x8.3'}), (10, {'res': '$const10.4'}), (12, {'index': '$const10.4', 'target': '$x8.3', 'res': '$12binary_subscr.5'}), (14, {'lhs': '$6binary_subscr.2', 'rhs': '$12binary_subscr.5', 'res': '$14compare_op.6'}), (16, {'res': '$x16.7'}), (18, {'res': '$const18.8'}), (20, {'index': '$const18.8', 'target': '$x16.7', 'res': '$20binary_subscr.9'}), (22, {'res': '$x22.10'}), (24, {'res': '$const24.11'}), (26, {'index': '$const24.11', 'target': '$x22.10', 'res': '$26binary_subscr.12'}), (28, {'lhs': '$20binary_subscr.9', 'rhs': '$26binary_subscr.12', 'res': '$28compare_op.13'}), (30, {'lhs': '$14compare_op.6', 'rhs': '$28compare_op.13', 'res': '$30binary_and.14'}), (32, {'retval': '$30binary_and.14', 'castval': '$32return_value.15'})), outgoing_phis={}, blockstack=(), active_try_block=None, outgoing_edgepushed={})
DEBUG:numba.core.interpreter:label 0:
    x = arg(0, name=x)                       ['x']
    $const4.1 = const(int, 0)                ['$const4.1']
    $6binary_subscr.2 = getitem(value=x, index=$const4.1, fn=<built-in function getitem>) ['$6binary_subscr.2', '$const4.1', 'x']
    $const10.4 = const(int, -1)              ['$const10.4']
    $12binary_subscr.5 = getitem(value=x, index=$const10.4, fn=<built-in function getitem>) ['$12binary_subscr.5', '$const10.4', 'x']
    $14compare_op.6 = $6binary_subscr.2 < $12binary_subscr.5 ['$12binary_subscr.5', '$14compare_op.6', '$6binary_subscr.2']
    $const18.8 = const(int, 0)               ['$const18.8']
    $20binary_subscr.9 = getitem(value=x, index=$const18.8, fn=<built-in function getitem>) ['$20binary_subscr.9', '$const18.8', 'x']
    $const24.11 = const(int, 1)              ['$const24.11']
    $26binary_subscr.12 = getitem(value=x, index=$const24.11, fn=<built-in function getitem>) ['$26binary_subscr.12', '$const24.11', 'x']
    $28compare_op.13 = $20binary_subscr.9 <= $26binary_subscr.12 ['$20binary_subscr.9', '$26binary_subscr.12', '$28compare_op.13']
    $30binary_and.14 = $14compare_op.6 & $28compare_op.13 ['$14compare_op.6', '$28compare_op.13', '$30binary_and.14']
    $32return_value.15 = cast(value=$30binary_and.14) ['$30binary_and.14', '$32return_value.15']
    return $32return_value.15                ['$32return_value.15']
 
INFO:root:Audio preprocessing completed
ERROR:root:Error in audio processing pipeline: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()