dlutton / flutter_tts

Flutter Text to Speech package
MIT License
617 stars 258 forks source link

Play completed without calling #523

Open gamebug001 opened 2 months ago

gamebug001 commented 2 months ago

🐛 Bug Report

Play completed without calling

Expected behavior

Play completed call

Reproduction steps

Configuration

Version: 4.0.2 Flutter 3.22.2

Platform:

class:

class AiConsultationState {
  static final AiConsultationState _instance = AiConsultationState._internal();

  AiConsultationState._internal();

  factory AiConsultationState() {
    return _instance;
  }

  TextToSpeechPlayer ttsPlayer = TextToSpeechPlayer();
}

import 'package:askaide/helper/logger.dart';
import 'package:flutter_tts/flutter_tts.dart';

class TextToSpeechPlayer {
  final FlutterTts _flutterTts = FlutterTts();

  TextToSpeechPlayer() {
    _flutterTts.setLanguage("zh-CN"); // 根据语言设置
    _flutterTts.setSpeechRate(1.0);   // 设置语速
    _flutterTts.setVolume(1.0);       // 设置音量
    _flutterTts.setPitch(1.0);        // 设置音调
    _flutterTts.awaitSpeakCompletion(true);
    _flutterTts.setQueueMode(1);
    _flutterTts.setCompletionHandler(() {
      Logger.debugLog("播放完成tts+++");
      _onPlaybackComplete();
    });
  }

  speak(String result) {
    _flutterTts.speak(result);
  }
}

WeChatd18dc44b0694a144e0cff772948db78c

speak Play completed setCompletionHandler No Execute

arpit-batra-dev commented 1 day ago

I'm also facing the same issue