def find_frame(buffer):
  """
  Finds the next MP3 frame header.

  @param bytearray buffer
    Bytes from an MP3 file.

  @return int
    The index in the buffer where the frame was found, or -1 if not found.
  """
  try:
    synchs = [buffer.find(b'\xFF\xFA'), buffer.find(b'\xFF\xFB')]
    return min(x for x in synchs if x > -1)
  except ValueError:
    return -1