Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 음소 인식 페이지 오류 수정 #46

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/viewModels/record/record_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ class RecordViewModel extends GetxController {
}

Future<void> sendTextAndAudio(String content, int type) async {

isRecording.value ? await _stopRecording() : await _startRecording();
update();
if(isRecording.value == true) {
return;
}
print("들어오긴 함?");
String url =
'${dotenv.env['API_URL']!}/study/${type == 0 ? 'syllable' : (type == 1 ? 'word' : 'sentence')}';


print(audioFilePath.value);
if (audioFilePath.value.isEmpty) {
return;
Expand All @@ -85,14 +93,13 @@ class RecordViewModel extends GetxController {
final jsonResponse = json.decode(respStr);
//
this.response.value = jsonResponse;
} else {}
print(jsonResponse);
} else {
print('Failed to upload');
}
} catch (e) {}
}

void toggleRecording() async {
isRecording.value ? await _stopRecording() : await _startRecording();
update();
}

@override
void onClose() {
Expand Down
7 changes: 2 additions & 5 deletions lib/views/word/widget/word_sentence_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,15 @@ class WordSentenceWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(40),
onTap: () async {
if (model.isRecording.value) {
// 녹음 토글 버튼
print('녹음 종료');
model.toggleRecording();

await model.sendTextAndAudio(
wordDataList[wordViewModel.currentIndex.value]
.wordCard
.word,
type);

// Handle the response here, e.g., show it in a dialog
Get.dialog(
// height
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
Expand Down Expand Up @@ -182,7 +179,7 @@ class WordSentenceWidget extends StatelessWidget {
} else {
// Start recording
print('녹음 시작');
model.toggleRecording();
model.sendTextAndAudio('content', 0);
}
},
child: Padding(
Expand Down
Loading