语音转文字

This commit is contained in:
18401019693 2022-10-25 14:41:08 +08:00
parent 172b37ece2
commit 7e00a5e71e
6 changed files with 46 additions and 34 deletions

View File

@ -1,16 +1,15 @@
package com.yunbao.main.dialog;
package com.yunbao.common.dialog;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.R;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.main.R;
public class HintDialog extends AbsDialogFragment {
@Override
@ -31,7 +30,7 @@ public class HintDialog extends AbsDialogFragment {
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(com.yunbao.live.R.style.bottomToTopAnim);
window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = DpUtil.dp2px(277);
params.height = DpUtil.dp2px(134);

View File

@ -5,6 +5,8 @@ import android.util.Log;
import android.view.Gravity;
import android.view.View;
import androidx.fragment.app.FragmentActivity;
import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.interfaces.FloatCallbacks;
@ -14,6 +16,8 @@ import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.R;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.dialog.HintDialog;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.floatingview.FloatingMagnetView;
@ -66,6 +70,10 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
public void onViewClicks() {
mPlayer.stopPlay();
APPEasyFloat.getInstance().dismiss(mContext);
if (IMLoginManager.get(mContext).isHint()) {
HintDialog fragment = new HintDialog();
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
}
}
});
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
@ -155,6 +163,10 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
public void onViewClicks() {
mPlayer.stopPlay();
EasyFloat.dismiss("LiveFloatView", true);
if (IMLoginManager.get(mContext).isHint()) {
HintDialog fragment = new HintDialog();
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
}
}
});
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {

View File

@ -20,8 +20,6 @@ import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.SpeechRecognizer;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity;
@ -83,7 +81,7 @@ public class VoiceDialog extends AbsDialogFragment {
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(com.yunbao.common.R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width =WindowManager.LayoutParams.WRAP_CONTENT;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.CENTER;
window.setAttributes(params);
@ -107,25 +105,32 @@ public class VoiceDialog extends AbsDialogFragment {
* 上划取消
*/
public void withdraw() {
voiceFluctuations.setVisibility(View.GONE);
gifView.setVisibility(View.GONE);
iconWithdraw.setVisibility(View.VISIBLE);
fingersSlide.setText(getString(R.string.release_cancel_send));
isSend = false;
if (!isDetached()) {
voiceFluctuations.setVisibility(View.GONE);
gifView.setVisibility(View.GONE);
iconWithdraw.setVisibility(View.VISIBLE);
fingersSlide.setText(getString(R.string.release_cancel_send));
isSend = false;
}
}
/**
* 上划取消
*/
public void notWithdraw() {
if (TextUtils.isEmpty(sendMessage())){
voiceFluctuations.setVisibility(View.VISIBLE);
}else {
gifView.setVisibility(View.VISIBLE);
if (!isDetached()) {
if (TextUtils.isEmpty(sendMessage())) {
if (gifView.getVisibility() != View.VISIBLE)
voiceFluctuations.setVisibility(View.VISIBLE);
} else {
if (voiceFluctuations.getVisibility() != View.VISIBLE)
gifView.setVisibility(View.VISIBLE);
}
iconWithdraw.setVisibility(View.GONE);
fingersSlide.setText(getString(R.string.fingers_slide));
isSend = true;
}
iconWithdraw.setVisibility(View.GONE);
fingersSlide.setText(getString(R.string.fingers_slide));
isSend = true;
}
/**
@ -134,7 +139,7 @@ public class VoiceDialog extends AbsDialogFragment {
RecognizerListener recognizerListener = new RecognizerListener() {
@Override
public void onVolumeChanged(int volume, byte[] bytes) {
if (volume > 10) {
if (volume > 10) {
gifView.setVisibility(View.VISIBLE);
voiceFluctuations.setVisibility(View.GONE);
}

View File

@ -290,11 +290,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
float moveY = event.getY();
if (downY - moveY > 120) {
if (voiceDialog != null)
if (voiceDialog != null && voiceDialog.isAdded())
voiceDialog.withdraw();
}
if ((downY - moveY < 100) && (downY - moveY > 30)) {
if (voiceDialog != null)
if (voiceDialog != null&& voiceDialog.isAdded())
voiceDialog.notWithdraw();
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
@ -326,7 +326,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
public void run() {
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(30);//震动时间(ms)
vibrator.vibrate(100);//震动时间(ms)
if (voiceDialog == null) {
voiceDialog = new VoiceDialog();
}

View File

@ -93,7 +93,6 @@ import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import com.yunbao.live.utils.LiveStorge;
import com.yunbao.live.views.ChatListViewHolder;
import com.yunbao.main.R;
import com.yunbao.main.dialog.HintDialog;
import com.yunbao.main.dialog.MainStartDialogFragment;
import com.yunbao.main.dialog.ReturnUserDialog;
import com.yunbao.main.dialog.SigninDialog;
@ -476,16 +475,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override
protected void onRestart() {
super.onRestart();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (IMLoginManager.get(mContext).isHint()) {
HintDialog fragment = new HintDialog();
fragment.show(getSupportFragmentManager(), "HintDialog");
}
}
}, 1000);
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
//
//
// }
// }, 1000);
}
/**