You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境Python3.6.3开发Jarvis AI无输出问题求助

Troubleshooting Your Jarvis AI Talk Function (Windows 10 + Python 3.6.3)

Let's break down why your talkToME function isn't producing any output or audio—even without throwing errors. Here are the most likely issues and fixes tailored to your setup:

1. You never called the function!

Looking at your code, you’ve defined the talkToME function but never actually executed it. Functions only run when you explicitly call them. Add this line at the end of your script to trigger the behavior you expect:

talkToME("I am fine")

Without this, your code just defines the function and exits silently—no wonder you don’t see or hear anything.

2. mpg123 isn’t available on Windows

The os.system('mpg123 audio.mp3') command relies on mpg123, a command-line audio player that doesn’t come pre-installed on Windows. Even if you’ve installed it, if it’s not added to your system PATH, Windows won’t locate it.

A simpler, Windows-native fix is to use os.startfile(), which opens the audio file with your default media player:

os.startfile('audio.mp3')

Replace the mpg123 line with this, and you won’t need extra software to play the audio.

3. File permission issues when saving the audio

Your script might not have permission to save audio.mp3 in its current working directory. Try using an absolute path to a folder you know you can write to (like your Documents folder):

# Replace "YourName" with your actual Windows username
audio_path = 'C:/Users/YourName/Documents/jarvis_audio.mp3'
tts.save(audio_path)
os.startfile(audio_path)

Check if the file appears in that folder—if not, double-check the folder’s write permissions.

4. Verify the audio file is being created

Before troubleshooting playback, confirm that audio.mp3 is actually being generated. Look in the folder where you run your script for the file. If it’s missing, the gTTS.save() step might be failing silently (older Python 3.6 packages can sometimes behave this way). Try upgrading gTTS to a version compatible with Python 3.6:

pip install --upgrade gTTS

Working Modified Example

Here’s a revised version of your code that addresses all these common issues:

from gtts import gTTS
import os
import speech_recognition as sr
import webbrowser
import time

def talkToME(audioString):
    print(audioString)
    tts = gTTS(text=audioString, lang='en')
    # Use a writable absolute path
    audio_path = 'C:/Users/YourName/Documents/jarvis_response.mp3'
    tts.save(audio_path)
    # Windows-native audio playback
    os.startfile(audio_path)

# Trigger the function with your expected message
talkToME("I am fine")

内容的提问来源于stack exchange,提问作者Brian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:27:57