Home / Expert Answers / Computer Science / i-39-m-having-an-issue-in-my-code-with-two-specific-problems-34-expected-expresssion-and-try-stateme-pa701

(Solved): I'm having an issue in my code with two specific problems: "Expected expresssion and Try statement ...



I'm having an issue in my code with two specific problems: "Expected expresssion and Try statement must have at least one except or finally clause." Below is the section of code that I'm having this issue with: # Function to recognize spoken numbers using cepstrum def recognize_number(input_signal, sample_numbers): try: cepstrums = [] for digit, sample_data in sample_numbers.items(): # Check lengths of input_signal and sample_data print(f"Length of input_signal: {len(input_signal)}, Length of sample_data: {len(sample_data)}") # If they're not the same length, you can pad the shorter one with zeros at the end if len(input_signal) != len(sample_data): if len(input_signal) < len(sample_data): input_signal = np.pad(input_signal, (0, len(sample_data) - len(input_signal))) else: sample_data = np.pad(sample_data, (0, len(input_signal) - len(sample_data))) # Perform correlation corr = correlate(input_signal, sample_data, mode='full', method='fft') cepstrum = np.abs(np.fft.ifft(np.log(np.abs(corr) + 1e-10)))[:len(input_signal) // 2] cepstrums.append(cepstrum) cepstrums = np.array(cepstrums) similarity_scores = np.max(cepstrums, axis=1) recognized_digit = np.argmax(similarity_scores) return recognized_digit except Exception as e: print("Error occurred: {e}") return None Is there anyone that can help me out with this? I don't understand how to fix those two errors.



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe