你說:
I use the following JavaScript code to allow the user to select a file. Can you help me adjust the code so that it loads an initial file, "sentences.txt" automatically?
fileInput.addEventListener('change', e=>{
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.readAsText(file);
reader.onload = () => {
const lines = reader.result.split(/\r?\n/).map(l => l.trim()).filter(l => l);
sentenceList.innerHTML = '';
lines.forEach(line=>{
const li = document.createElement('li');
li.textContent = line;
li.addEventListener('click', ()=> speakFiltered(line, li));
sentenceList.appendChild(li);
});
};
reader.onerror = () => alert('Error reading file.');
});